How to install multiple version of node.js in Ubuntu using NVM?
4 Answers
prior knowledge
How to use the terminal. You can for example use gnome-terminal
.
Install dependencies
sudo apt-get install build-essential libssl-dev curl git-core
Install NVM
Below we will install NVM.
Download nvm
git clone https://github.com/creationix/nvm.git ~/.nvm
To activate nvm, you need to source it from your bash shell
echo -e "\n. ~/.nvm/nvm.sh" >> ~/.bashrc
Install version of node.js
In this example, I am going to install node v0.4.12. We first need open new bash session. You can also do this by typing bash
again.
$ bash
$ nvm install v0.4.12 #This takes a while.
To make the latest v0.4 branch default you do
$ nvm alias default 0.4
Troubleshooting
When you don't have all dependencies installed you can not compile/install node.js. Then you will need to clean up ~/.nvm
$ rm -rf ~/.nvm/

- 1,932
- 19
- 29

- 60,935
- 33
- 147
- 186
-
19That echo line caused me some issues on Ubuntu 12.04. Had to edit the file and change it to `source ~/.nvm/nvm.sh` – jcollum Jul 19 '13 at 16:22
Here is a detailed, up-to-date manual: https://www.digitalocean.com/community/articles/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps#installation

- 33,955
- 36
- 114
- 183
The top answer is out of date. Now, just follow the guide on the github to install :
https://github.com/creationix/nvm#installation
For linux machines, its as simple as :
curl -o- https://raw.githubusercontent.com/creationix/nvm/v*/install.sh | bash
Replace v*
with the latest version from https://github.com/creationix/nvm/releases.
For example:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

- 3,878
- 2
- 34
- 47

- 6,352
- 5
- 42
- 59
Install Node.js with Node Version Manager in linux (Ubuntu, linux mint)
1. Build essential package
sudo apt-get install build-essential checkinstall
2. Get libssl-dev
sudo apt-get install libssl-dev
3. Install nvm using cURL
curl -o- https://raw.githubusercontent.com/cre... | bash
4. Check installation work
command -v nvm
5. List available node versions
nvm ls-remote
6. download, compile and install node
nvm install 6.14.4
7. Tell nvm which version to use
nvm use 6.14.4
8. Set default node version
nvm alias default node 6.14.4

- 955
- 1
- 13
- 26