Ubuntu 14.04 and node.js

How to prepare new machine for node.js

I’ve been doing following steps quite often recently and putting them down here so that others may benefit from them.

The first step is to install the latest node.js version. The default one available in the system package manager is woefully outdated.

Following the official instructions (which I alwasy have much trouble finding):

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

To be able to compile any npm module with native addons one needs the C compiler and its friends. Thankfully in Ubuntu, all that is packages in build-essentials package.

$ sudo apt-get install -y build-essential

The last step is to get git. To install dependencies residing in a git repository (it should be a rare occasion, but it happens).

That should be enough.

If npm complains that it is outdated the simplest fix is to run:

$ sudo npm install -g npm@latest

Now the brand new Ubuntu 14.04 machine should be ready to run any node.js application.