- remove_red_eye7330 Views
- event22 Nov 2016
- access_time2 min read
Due to dependency issues and upgrade in Node.js versions, some applications still requires old Node.js versions.
In the scenario, where you need to run two or more applications which require a different version of Node.js you either need to upgrade or downgrade the Node.js version in the system and that sometimes becomes the root of many issues.
Node version manager
No more of this. You can install multiple version of Node.js in a single machine and can run different programs with a different version of Node.js.
Introducing Node version manager by Creationix. This script manages multiple active Node.js version to install and run Node.js program with different Node.js version.
To install NVM, you need CURL or WGET program installed in your machine.
I have installed using CURL. Here is the command.
You can install using WGET too.
Once installation is done, export the NVM as command line tool using following command.
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
Installing Node.js using NVM
If you want to install latest version of Node.js then run following command.
If you want to install a specific version, run the following command.
Install as many as you would need.
Running Node.js program using NVM
Say you want to run one program using Node.js version 4.2.5. Run it using following command.
Replace version number with any installed version and NVM will execute it for you.
You can also set the Node.js version for the terminal session (Each tab on the terminal is different terminal session) using the following command.
Then run the app using standard Node.js command.
This is short tip post and I hope it helps you to solve such issue where you need to run multiple Node.js application with different Node.js version.