Node is fairly new and is constantly improving. With Ubuntu LTS, the repository versions tend to stay the same version and only changing for patches. This doesn’t help with fast changing software like node.js so a manual install gets around this.
Install the required packages:
sudo apt-get install build-essential libssl-dev curl
Go to http://nodejs.org and download the Linux binaries for either 32 or 64 bit. At the time I got node-v0.10.28-linux-x64.tar.gz so this will be used as the example from here on.
This guide will go through installing using root but it can also be installed without by using a different path to /usr/local e.g ~/local/
Extract the downloaded file to the directory created above:
sudo tar -xzf ~/Downloads/node-v0.10.28-linux-x64.tar.gz -C /usr/local
Rename the directory so that it is not version specific:
sudo mv /usr/local/node-v0.10.28-linux-x64 /usr/local/node
Add the binary executable directory to the shell path to save typing /usr/local/node/bin/[something]. Edit /etc/environment and append :/usr/local/node/bin onto the end of the PATH= inside the quotes. For example from:
For non root, edit ~/.bashrc file and append this to the file:
Reload bash shell to pick up the changes. Root install:
To check the install worked, type the following and the prompt should change:
NPM is installed as part of node.js but it doesn’t have execute permissions. To enable this:
sudo chmod +x /usr/local/node/lib/node_modules/npm/bin/npm.cmd
To test it works type:
Small inconvenience to get the latest and greatest.