Run Multiple Node Version of NodeJs Using NVM in Windows
When we developing Node.js applications we might face situations where we need to install multiple versions of Node. Like We have old projects which is run in Node Version 5 and others old node version but we want to work on angular 2 and angular 4 (Angular 2 and Angular 4 need at least node 6.9.x or above) then we need to install Latest version of Node but in this case may be our old projects are not running. NVM solves this issue for us.
NVM (Node Version Manager) :-
With the help of NVM, we manage and switch between different Node versions. NVM provides a command line interface where we can install different versions with a single command, set a default, switch between them and much more.
Step 1 : Install NVM for Windows :-
Download Link for NVM :- https://github.com/coreybutler/nvm-windows/releases
First, we need to install NVM for Windows. We will install the latest release of this tool (v1.1.6). The installation is very easy. Just follow the prompts of the Setup Wizard.
Sometime After the end of the installation there is a chance the CLI will crash with following error.
“ERROR open \setting.txt: The system cannot find the specified file”
for solve this error follow these steps:
Go to c:\Users\{username}\AppData\Roaming\nvm folder, copy settings.txt and paste it to c directory .
Step 2: Install Node.js Version
For install node version just run following command in CMD, here We install version 8.7.0 for 64-bit Windows by running the command:
$ nvm install 8.7.0 64
Similarly, we can install as many Node.js versions as we want.
Step 3: List available Node.js versions
To see all the Node.js versions installed on our machine, simply run following command:
$ nvm ls
this command return the all available version of node which is install in system.
Step 4: Use a specific Node.js version
Run following command to set node version in system.
$ nvm use 8.7.0
Now to check running version of node just run following command:
$ node -v
Very,very good!
Thanks Rusu Silvia!
It works perfectly, until I want to use npm command. when I executed npm command, It says ‘npm’ is not recognized as an internal or external command,operable program or batch file.