How to install node on Ubuntu/Debian ?

What is node / nodejs ?

I used to say that nodejs is an JavaScript application server, build on chrome JavaScript engine. We can say that you write some application in JavaScript and node run your application like a web server do. Some kind of Apache web server that run your PHP and html files.

Note: You should know that there are actually 3 version of nodejs server out there. You have version 0.10, 0.12 and 4.0. I should also warn you guys when you are installing node please check the requirements the applications that will use node well before choosing the version that you are about to install on your machine. An application that runs on 0.10 may not run on 0.12 or 4.0. So be very careful guys on choosing your version.

Nodejs install instructions:

Node 0.10x :

# On Ubuntu

curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs

# On Debian, as root

curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs

Node 0.12x :

# On Ubuntu

curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs

# On Debian, as root

curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs

Node 4.0x :

# On Ubuntu

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

# On Debian, as root

curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs

Quick way to install Nodejs on ubuntu

Here is how to install the package manager for node which is “npm” with nodejs v0.10 :

$sudo apt-get install npm build-essentials

When you install nodejs from the package manager of your machine you will find that you don’t have the node binary in your /usr/bin/ and some application will look for the binary node instead of nodejs in your /usr/bin. Here is the trick :

$cd /usr/bin/
$ln -s /usr/bin/nodejs node

Now you can launch your application simply by typing node main.js.

Tips:

To run the application in background :

$node main.js > /dev/null &

For more documentation and check if your Linux distribution supports it visit the source.

Article by Ash

“Your eyes can deceive you. Don’t trust them.” – Obi-Wan Kenobi