How to Install an Upstream Version of Node.js on Ubuntu 12.04

What is Node.js ?


Node.js is a platform that uses event-driven, non-blocking I/O model for providing an easy way to build scalable network programs. It is built on JavaScript runtime and it is perfect for real time applications that run across distributed devices.


Initial Set Up


For the installation of Node.js, you will have to install the curl and compiler on your droplet. Before starting the installation, run an apt-get update as given below:

sudo apt-get update


Once the update is completed, you can go ahead and install compiler on your VPS.

sudo apt-get install build-essential


If you don’t have curl on your system, make sure you download it right away, as it’s required to perform the installation.

sudo apt-get install curl


Once you have these two components, curl and compiler, you are all set to install Node.js.


Installation of Node.js and Node Package Manager


According to the official documentation in their website, there are many ways to install Node.js. In this tutorial, I am using a particular method which I found easier and straight forward.

As the first step, change the paths to include the commands from the  ~/local/bin directory.

 echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc

Follow up by sourcing .bashrc file as shown below:

. ~/.bashrc

Now, you have to create two new directories for the installation:


mkdir ~/local

mkdir ~/node-latest-install

Navigate to the latest-install folder.


cd ~/node-latest-install

After that, run the curl to get the node.js tarball and untar it.


curl | tar xz --strip-components=1

Once it is finished,  you can start the installation process for the local user. This ensures that you will not need sudo later.


./configure --prefix=~/local

Now, run the command make install. Make sure that you don’t interrupt as it takes a while to install.


make install

You can finish up by downloading the npm through curl:


curl -L | sh

Once it’s done, you can quickly verify the version installed on your vps.

node -v

support2 has written 111 articles

Leave a Reply