https://keymetrics.io/2015/02/03/installing-node-js-and-io-js-with-nvm/
http://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/
What is nvm?
nvm abbreviate for Node Version Manager.
How can we install nvm?
sudo apt-get update
sudo apt-get install build-essential libssl-dev
curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
At this moment NVM should be properly installed, so we will logout and login to verify that
nvm
If there's no error when typing in the nvm command, that means that everything's alright.
How can we list available version of node so that we can install them?
nvm list available
How can we install a particular version of node?
nvm install v0.10.31
nvm alias default 0.10.31
How can we switch between different version of Node?
nvm use v0.8.10
How can we make sure that we always use a particular version of Node?
nvm alias default 0.10.31
How can we list the various versions of Node that we have installed?
nvm list
How can we support multiple versions of Node?
There are native installers for Node on Windows and OS X, as well as the possibility of installing it via a package manager. However sometimes you will want to test your code with different Node versions, and that's where NVM (Node version manager) comes in. With NVM you can have multiple versions of Node installed on your system and switch between them easily. In the next few lines we are going to see how to install NVM on an Ubuntu system.
First, we have to make sure our system has a C++ compiler:
sudo apt-get update
sudo apt-get install build-essential libssl-dev
After that we can copy-paste the one-line installer for NVM into the terminal:
curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
At this moment NVM should be properly installed, so we will logout and login to verify that:
nvm
If there's no error when typing in the nvm command, that means that everything's alright. Now we can move on to actually installing Node and npm.
nvm install v0.10.31
Both node and npm should be available in the terminal now:
node -v && npm -v
There is one last thing we need to do so we can always use this version of Node when we login the next time: making this version the default one.
nvm alias default 0.10.31
We can install other Node versions just like we did before and switch between them with the nvm use command:
nvm install v0.8.10
nvm use v0.8.10
In case you are not sure what versions you have installed on your system just type nvm list. That will show you the full list of versions and also the current and default versions, such as the following:
nvm list