This article will walk you through the step-by-step process of installing node.js (with npm) from source on Ubuntu. If you're using a linux distribution other than Ubuntu, you can probably still follow the instructions here, except with a few minor changes to match your distro's way of doing things.


Install build dependencies:

sudo apt-get install g++ make


Create the ~/.npmrc file:

vim ~/.npmrc

Set the contents of the ~/.npmrc file to the following:

root = ~/.local/lib/node_modules
binroot = ~/.local/bin
manroot = ~/.local/share/man

Create the ~/.local directory:

mkdir ~/.local

Building Node.js from Source

Download the latest stable release of nodejs. We'll use 0.10.29 here, because that was the latest stable release as of the time this article was written:

wget ~/

Unpack the gzipped archive:

tar -xzvf ~/v0.10.29.tar.gz

Change directories into the directory that was just created:

cd ~/node-0.10.29

Configure the build:

./configure --prefix=~/.local

If you encountered errors during the configure step, you may need to check that all dependencies are met by looking at the file in the unpacked source directory.

After you have successfully configured the build, you can initiate the build process:


This will take a while.

Installing Node.js

Once the build process has finished, run the installation:

make install

Create .node_modules symlink:

ln -s ~/.local/lib/node_modules ~/.node_modules

Add npm to your $PATH by adding the following to the end of the ~/.profile file:

export PATH=$HOME/.local/bin:$PATH

Verifying the Installation

To verify that node was installed correctly:

node -v

Should output the correct version number for node, like this:


And to verify that npm was installed correctly:

npm -v

Should output the correct version number for npm, like this:


Clean up

Once everything has been installed and is working properly, you can go ahead and delete the source files:

rm -R /home/nodejs-0.10.x/node-0.10.29
rm /home/nodejs-0.10.x/v0.10.29.tar.gz