DEV Community

Guido Zambarda
Guido Zambarda

Posted on • Originally published at iamguidozam.blog on

NVM – Node Version Manager

Sometimes I need to have multiple Node.js version installed on my machine, maybe it’s only me but if you have my same problem the solution exists and it’s name is NVM.

I usually develop on Windows so I installed NVM for Windows from here, but if you’re on other OS I’m sure you can find a version that supports it, probably this is the answer.

NVM let’s you have multiple Node.js version installed simultaneously on your machine and you can select with which version to work.

With NVM for Windows, in my opinion, four of the most useful commands are:

  • nvm install
  • nvm list
  • nvm uninstall
  • nvm use

Let’s have a look a little bit more in detail to each command.

install : accept the version of Node.js that you want to install alongside the already installed ones.

list : returns all the Node.js version installed.

uninstall : accept the version of Node.js that you want to uninstall.

use : this command is used to change the working version with the one specified when executing the command.


Examples

Say that you want to install the latest version of Node.js 20, you can achieve it with:

nvm install 20
Enter fullscreen mode Exit fullscreen mode

Which lead to an output like the following:

After the installation you can check all the installed versions using:

nvm list
Enter fullscreen mode Exit fullscreen mode

In my demo environment the output is the following:

As you can see I’m currently using version 18, I’ve just installed version 20 and I want to start using it, so the next step will be to specify which version NVM should use:

nvm use 20
Enter fullscreen mode Exit fullscreen mode

After specifying the new version the list command would output something like:

Of course you cannot use a version that you haven’t previously installed, saying that you want to use version 19, the result would be:


And that’s it, using NVM you can now use multiple Node.js version on your machine.

Hope this helps!

Top comments (2)

Collapse
 
jaloplo profile image
Jaime López

NVM is a must if you develop custom code in SharePoint Online.

It happens to me to take the development of another company and add some more features. It only was 1 year old but SPFx environment had changed a lot since then.

Having different versions of Node.js makes easier to deal with different SPFx versions.

Great article ;)

Collapse
 
guidozam profile image
Guido Zambarda

Thanks for the feedback!

I used to pull my hairs (that's why I'm bald :D ) maintaining various projects with different Node.js version and NVM was a great discovery, is an amazing tool to manage those situations!