Disclaimer: This is about nvm for windows. If you are on mac/linux follow this link to find the correct version.
Have you ever experienced difficulties with a project because you are on the wrong node version? I have! A lot of projects break, or won't build, if you don't have the required version. Previously I used to uninstall/install the correct version manually. And it was a pain everytime. And what if you are working on multiple projects that all uses different node versions? This is where NVM comes in handy.
With nvm you can have multiple versions of node installed at the same time, and easily switch between them! In this blogpost I will show you how to install and use nvm.
Installing nvm for windows
Go to nvm-windows github repo and download the zip-file containing the installation wizard.
Run the installation wizard, click next a bunch of times, and then wait while it installes on your computer.
When its finished open your CLI (command line interface). I use windows terminal, but regular command prompt (or any other) will do to. If nvm installed correctly you can now run nvm version and get the version number in return.
nvm version
Using nvm
Install versions of node
Now you can start installing different node versions. You do this by running nvm install and the version number you would like to install. So if you want to install node version 10.23.2, you would run the following command
nvm install 10.23.2
See the versions you have installed
To see what versions you have already installed simply run nvm list
In the above picture you can see that I have installed seven different versions of node, and I'm currently using 10.23.2.
Switch between versions
To switch version run nvm use followed by the version number
nvm use 12.21.0
And thats it! You can now switch between different versions.
Worth noticing
Its written so well in the documentation so I will simply quote it here:
Please note that any global npm modules you may have installed are not shared between the various versions of node.js you have installed. Additionally, some npm modules may not be supported in the version of node you're using, so be aware of your environment as you work.
Did you find this article usefull? Follow me on twitter to be notified when I publish something new!
Also, if you have any feedback or questions, please let me know in the comments below. :)
Thank you for reading, and happy coding!
/Eli
Top comments (0)