How to Setup Node.JS on Ubuntu 15.04 with Different Methods

This is such an important article to guide you about the installation and setup of Node.js on Ubuntu 15.04. Node.js is basically a server side java script programming to provide you bindings for enabling the input and output socket bios and streams. It has a high through put and non-blocking IO in a single threaded event loop. It’s also a platform layer that provides the functionality to interact with the Operating system to write file, read files and to do networking operations. So in this article we will perform different installation methods to setup Node.Js on Ubuntu 15.04 server.

Methods to Install Node.JS

Their are different ways to install Node.Js and we can prefer to choose any one. Following are some important ways to install Node.Js that we will use to guide you about their each setup on Ubuntu 15.04 so make sure to remove the previous previous packages to avoid from any package conflict.

  • Installation of Node.JS from Source Code
  • Installation of Node.JS from Package Manager
  • Installation of Node.JS from Github Repository
  • Installation of Node.JS with NVM

1) Installing from Source Code

Let's start with installation of Node.JS from the Source Code, so make sure that your system is up to date and dependent packages are pre installed. So follow the below steps and start the setup.

STEP 1: System Update

Use following commands and update Operating system and ten install the required packages are necessary for Node.JS setup.

[email protected]:~# apt-get update

[email protected]:~# apt-get install python gcc make g++

STEP 2: Get Source Code of Node.JS

After we had installed the dependent packages now from the official web link of Node.JS just download its source code package and extract it as in following commands.

[email protected]:~# wget
[email protected]:~# tar zxvf node-v0.12.4.tar.gz

STEP 3: Starting Installation

Now move to the source code directory and execute the .configuration file

NodeJS Configure

[email protected]:~# ls
node-v0.12.4 node-v0.12.4.tar.gz
[email protected]:~# cd node-v0.12.4/
[email protected]:~/node-v0.12.4# ./configure
[email protected]:~/node-v0.12.4# make install

Testing after Installation of Node.Js from Source Code

Once the installation is done after running make installa command, we check its version and test that Node.Js is working fine by executing some test out puts.

[email protected]:~/node-v0.12.4# node -v

Node.Js Test

Create a new file with .js extension execute it with Node command.

[email protected]:~/node-v0.12.4# touch helo_test.js
[email protected]:~/node-v0.12.4# vim helo_test.js
console.log('Hello World');

Now execute it with Node command.

[email protected]:~/node-v0.12.4# node helo_test.js
Hello World

The out put shows that we had successfully installed Node.JS on Ubuntu 15.04 which is now ready to create applications on it using java scripts.

2) Installing from Package Manager

The installation of Node.JS through Package Manager is also a very simple process to setup on Ubuntu through NodeSource by adding its Personal Package Archives (PPA).

We will go through the following steps to install Node.JS through PPA.

STEP 1: Get the Source Code using Curl

Before getting the source code by using the Curl command we must update our system and then run the curl command to fetch the NodeSource into local repository.

[email protected]:~#apt-get update
[email protected]:~# curl -sL | sudo bash -

The curl will execute the following tasks.

## Installing the NodeSource Node.js 0.10 repo...
## Populating apt-get cache...
## Confirming "vivid" is supported...
## Adding the NodeSource signing key to your keyring...
## Creating apt sources list file for the NodeSource Node.js 0.10 repo...
## Running `apt-get update` for you...
Fetched 6,411 B in 5s (1,077 B/s)
Reading package lists... Done
## Run `apt-get install nodejs` (as root) to install Node.js 0.10 and npm

STEP 2: Installation of NodeJS and NPM

As per the output of Curl we had fetched the NodeSource to our local repository now through apt-get commands we will install the NodeJS and NPM packages.

[email protected]:~# apt-get install nodejs

NodeJS Install

STEP 3: Installing Build Essentials Tool

To compile and install native addons from npm we may also need to install build tools using following command as.

[email protected]:~# apt-get install -y build-essential

Testing With Node.JS Shell

Testing of Node.Js is similar to the one that we did after installation from the source Code.
so lets start with the node command as follow and get its output result to see if Node.JS is fully functional.

[email protected]:~# node
> console.log('Node.js Installed Using Package Manager');
Node.js Installed Using Package Manager

ro[email protected]:~# node
> a = [1,2,3,4,5] [ 1, 2, 3, 4, 5 ] > typeof a
> 5 + 2
(^C again to quit)
[email protected]:~#

REPL For Your NodeJS Apps

REPL is the Node.js shell, any valid Javascript which can be written in a script can be passed to the REPL. So lets see how REPL works with NodeJS.

[email protected]:~# node
> var repl = require("repl");
> repl.start("> ");

Press Enter and it will show out put like this:
> { domain: null,
_events: {},
_maxListeners: 10,
useGlobal: false,
ignoreUndefined: false,
eval: [Function],
{ _connecting: false,
{ fd: 0,
writeQueueSize: 0,
owner: [Circular],
onread: [Function: onread],
reading: true },
{ highWaterMark: 0,
buffer: [],
length: 0,
pipes: null,

Here is the list of command line help that we can use to work with REPL.

REPL Manual

Working with NodeJS Packet Manager

NPM is simple CLI tool for ensuring that a given node script runs continuously. It helps to Install and manage dependencies through the file package.json. We will start its using init command as.

[email protected]:~# npm init

NPM starting

3) Installing from Github Repository

In this method to install Node.JS we will consider few simple steps to directory clone the Node.JS repository from the github.

Before the start of configurations through the the cloned package of Node.JS make sure that we must have following dependent packages installed with us.

[email protected]:~# apt-get install g++ curl make libssl-dev apache2-utils git-core

Now start the clone with git command and change the directory to its configuration file.

[email protected]:~# git clone git://
[email protected]:~# cd node/

Git Clone NodeJS

To install from the cloned repository now lets run the .config command and then make install to complete the setup of Node.Js .

[email protected]:~# ./configure

Configure Node

Run the make install command that will takes few minutes so be patient and get it ready finalize the setup on Node.JS package for you.

[email protected]:~/node# make install

[email protected]:~/node# node -v

Testing with Node.JS

[email protected]:~/node# node
> a = [1,2,3,4,5,6,7] [ 1, 2, 3, 4, 5, 6, 7 ] > typeof a
> 6 + 5
(^C again to quit)
[email protected]:~/node#

4) Installing Node.JS Using Node Version Manager

In this last method we show you we can easily install Node.JS with NVM method. This is one of the best method to install and configure Node.JS it provides us with facility to control versions.

So before starting with this method make sure that the previously installed package is not already present there if you are working on the same machine.

STEP 1: Installing Prerequisites

Let's start with the system update and then install the following prerequisites for the Ubuntu Server to setup Node.JS using NodeJS Versions Manager System. Using the Curl command we will get NVM from the git to our local repository.

[email protected]:~# apt-get install build-essential libssl-dev
[email protected]:~# curl | sh

NVM Curl

STEP 2: Update Home Environment

After the curl command downloads the necessary packages for the NVM in the home directory of the user it also make changes to the bash profile. so in order to update those change and get access to NVM we must relogin to the terminal or we can update it using the source command as below.

[email protected]:~# source ~/.profile

Now we can use the NVM to choose the default NVM version or by moving to the previous version of NVM that we can do so by using the following commands.

[email protected]:~# nvm ls
[email protected]:~# nvm alias default 0.12.4

NVM Default

STEP 3: Using NodeJS Versions Manager

We have successfully setup the NodeJS with NVM package and now can use it with its useful commands.

NVM Manual


Now we are ready to go with building server side applications with Node.JS and you are free to choose the best installation setup of your choice as we had done with four optional installations of Node.Js on the latest version of Ubuntu 15.04 with priority installation sequence, now its up to you to follow the one of your own choice and start coding with NodeJS.

Kashif Siddique 3:00 am

About Kashif Siddique

Linux Systems and Security Engineer in Information and Communication Technology. Results-driven ICT Professional and Open Source Geek with technical specialties in the area of Open Source Operating systems and Applications.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.

1 Comment