[Fresh] Install node.js on Ubuntu server 11.10 (x64) via nvm step by step guide
sudo apt-get -y install build-essential libssl-dev curl git cd ~ git clone git://github.com/creationix/nvm.git . ~/nvm/nvm.sh nvm install v0.6.7 # Current version as of this writing nvm use v0.6.7 curl http://npmjs.org/install.sh | sh # Optional to install npm but recommended
Note:
- It’s better to put the source command (. ~/nvm/nvm.sh) into your ~/.bashrc since the nvm command might get used quite often:
if [ -f ~/nvm/nvm.sh ]; then . ~/nvm/nvm.sh fi - If anything goes wrong during nvm install (for example, complaining certain library is not installed, I found the easiest way to re-start the install process is to install the missing library, followed by the removal of installation directory, ~/nvm/src/node-v0.6.7, for example
- On my ubuntu vm running off an i3 laptop, it took 7 minutes to install node.js v0.6.7, YMMV
- If you find yourself stuck inside node console, type command process.exit() to get out, solution found from here
Advertisement
Nice guide. Prefer to use N for Node version management.
Interesting point about N. I am not using N and I don’t think I will for the following reason:
You need to get npm installed before you can get N running, which means you need to get node.js installed first. This might not be a big deal for those know how to apt-get compile node.js from source (or install node through home brew in Mac). With nvm you can install your first node.js (with version choice) easily. So I think for new installation nvm is still a better choice.