To install node.js on Linux Ubuntu we’re going to use terminal.:
sudo apt-get install nodejs
Unfortunately, installing like this will give us version 0.6.12 which is not the latest one. So if we want the most recent version we need to compile it from source.
First of all we need to grab the most recent version from nodejs.org, and there download the source code which is going to be a .tar.gz file. After saving to disk we need to unzip it. Open the terminal and from there extrect the files. I saved my file node-v0.8.14.tar.gz into /home/Downloads.
We need to switch to super user to be able to perform the following tasks.
sudo su
Next switch directory to where we need to compile node.js
cd /usr/local/src/
Copy archive to current dir…
cp /home/kummar/Downloads/node-v0.8.14.tar.gz .
…and extract it.
tar -xzf node.v0.8.14.tar.gz
Go to newly created dir (which is going to be called something like node-[ver] ie. mine was node-v0.8.14)
cd node-v0.8.14
run the configuration…
./configure
…make…
make
…and install.
make install
After successfull instalation we can log out from super user’s account.
exit
We can confirm successful instalation by checking what version is installed.
node -v
We should see something like this
node v0.8.14
Congratulations, you have got the latest and greatest version of node.js installed on your system. But wait, what is going to happen if next version comes out? Oh well…
Captain obvious to the rescue! nvm which stands for node version manager but that is a topic for another time.