How to install Node.js and NPM on a Debian (or Debian-based) Linux box


#1 way of getting node

There is a few ways of doing this. The easiest way is definitely to just install it through the apt-get package manager. This can be done with:
$ sudo apt-get install node

It is clever to run an update for the package manager before installing. This can be done with:
$ sudo apt-get update

Or just the whole thing as one line:
$ sudo apt-get update && apt-get install node

You will get the latest most stable build by doing this. There is a few limitations this way. If you would like to have some more control over the versions, i would recommend you doing the installation through Git and Make.

#2 way of getting node

Install the dependencies for this. Make is already a part of your Debian box. To do this install Git, CURL, build-essential and SSL software openssl + libssl-dev, from apt-get:
$ sudo apt-get install git-core curl build-essential openssl libssl-dev

It is always a good idea to update your package manager before you install/upgrade, like we did in example #1 with $ sudo apt-get update.

Now we are ready to use Git (http://git-scm.com).

Clone (download) the latest Node.js repository:
$ git clone https://github.com/joyent/node.git

Now change directory ($ cd node) into your newly cloned directory of Node.

You now have the possibility to choose whatever version you would like to use of Node. Check this through Git by running $ git tag. This will give you all the versions of Node. I will choose the latest one which at the moment is v0.10.22, so i run:
$ git checkout v0.10.22

Now you are on the latest version of Node.js. You are now able to configure the source, compiling the source, and build and install it on your Debian server.

Inside the node directory run:
1) $ ./configure --openssl-libpath=/usr/lib/ssl to configure the source.
2) $ make to compile the source.
3) $ make test to test install.
4) $ make install to install.

Hopefully the process has been smooth, and you should be ready to roll with Node.js. Test if we have succesfully installed it by running: $ node -v. This will return the current version (0.10.22).

comments powered by Disqus