You may need a previous version of the nodejs while working on several projects, and others need a new version of nodejs, or to check the new NodeJs functionality, you need to instal the newest version of the nodejjs While working on several projects of NodeJs.
As on the same machine, we can only install one version of the nodejs, so it’s very painful to uninstall and install the new node version as per your project requirements.
To overcome this problem, we can use the Node Version Manager (NVM). NVM allows installing multiple node js versions on the same machine and switching between the required node js version.
Installation of NVM
Windows
Download the latest version of NVM
https://github.com/coreybutler/nvm-windows/releases/latest
Download nvm-setup.zip and install on the windows
Verify Installation
nvm version
MacOs/Linux
Using curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Using Wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Verify Installation
command -v nvm
Usage
Get a List of all available NodeJs versions
nvm ls available //windows
nvm ls-remote //MacOs/Linux
Install latest NodeJs version
nvm install node
Install latest LTS Release
nvm install –lts
Install particular NodeJs version
Multiple NodeJs version can be installed using the below command.
nvm install 8.11.1 // to install the 8.11.1 version
nvm install 12.13.1 //to install the 12.13.1 version
UnInstall the multiple NodeJs version
nvm uninstall 8.11.1
Read this blog to learn more about installing multiple nodejs versions on the same machine.