How To Install and Manage Node.js with NVM. NVM is known as Node Version Manager. Like RVM (Ruby Version Manager) NVM provides an option for easy installation of Node.js. You can also installed multiple versions of nodejs on same system using nvm.
1. Install NVM
First you need to install NVM on your system. A bash script is available to install nvm on your system. Use following command to install NVM on your Linux system.
# curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Reload system environment using this command. It will set the required environment variables to use nvm on system.
# source ~/.profile
2. Install Node.js
This command will list all the available version of node.js to be installed and highlight the version your are currently using.
# nvm ls-remote
Now install required version of node.js. Below command will install node.js 6.0.0 on your system.
# nvm install 6.0.0
Repete the above command with different-2 node.js version to install multiple versions of node.js.
3. Set Default Node.js Version
Now use below command to select specific version of node.js to load in environment.
# nvm use 6.0.0
Now verify current active version of node.js
# node --version
4. Run App with Specific Version
If you have multiple node.js applications on your system and want to run each with specific version of node.js. NVM provides you an option to use node.js version for running any application. For example
# nvm run 6.0.0 app.js
5. Remove Node.js
This command will provide a list of installed versions of node.js on your system.
# nvm list
Below command will delete node.js 6.0.0 from your system. Change 6.0.0 with specific version you want to remove from system.
# nvm remove 6.0.0