Backstory
Have you ever experience difficulties in software development due to unsupported / different version ? Recently I was facing the same issue. The issue was a different Node.js version from my machine (Node v14.18.0) with my company project repository (Node v10 required). The first solution that instantly pop up in my mind was "I think downgrade my current node by uninstalling it will do the work", But what if you need another version for another project in the near future? Do you want to endure the pain of installing and uninstalling Node.js every time you need a different version of it ?
Node Version Manager
NVM is a version manager for Node.js, it allows you to quickly install and use different versions of node via the command line.
Let's head to the tutorial !
Instaling Node Version Manager Guide
If you happen to use UNIX, macOS, or WSL (Window Sub-system for Linux), you can install and read the official documentation here
If you happen to use Windows you can install it at NVM for windows which is developed by Corey Butler, download the nvm-setup.zip file.
Important Note
It is stated that you need to uninstall pre-existing node version, but based on my experience it is not necessary to do so.
After the installation you can open your command prompt and check whether nvm is recognized
C:\Users\YourUsername>nvm -v
Running version 1.1.8.
If nvm is not recognized as internal command or external command, try to re-open your command prompt.
Then, You can type nvm list in order to see list of Node.js version on your machine.
C:\Users\YourUsername>nvm list
* 14.18.0 (Currently using 64-bit executable)
10.18.0
If you don't see your desired Node.js version in the list, you can use nvm install command, for example if you want Node.js version 8, you can type nvm install 8.0.0
To use the installed Node.js version you can simply type nvm use 8.0.0
Note
If you see an error message exit status 5: Access is denied., It is due to admin privilege issue. To solve it you can simply run your command prompt as administrator.
Thank you for your time reading this short article / tutorial about Node Version Manager, hope it helps! and Have a great day.
Top comments (5)
I personally prefer the
n
npm package. I find it very simple to use and very intuitive. 🤔Ah yes, I just look into n, which can be directly installed via npm, the installation is much easier I guess.
Yes, I once tried to use
nvm
, but had some problems during the installation, so I triedn
and it worked like at charm.However, once
nvm
is installed, I guess it works pretty much the same asn
.I love nvm too. Had been using it for many years. Recently I'm also trying out asdf. It's very much like nvm, but supports many other tools as well. I like its
.tool-versions
file particularly that I can specify the versions for different projects. asdf will choose the correct version automatically when I swtich the project.What about nodenv?