How to setup node.js


What is Node.js? (
Node.js is a server side software system platform which is used for writing scalable and fast internet web applications.

Programs are usually written in JavaScript. They are event-driven and built on Chrome’s JavaScript runtime for easy building fast, non-blocking I/O model which makes it very efficient, lightweight and excellent for high traffic, data intensive and real time dynamic web applications that run on distributed devices.

Using Node.js in the cloud
Node.js has proven results in industry by using one language throughout the whole JavaScript Stack. It also allows us to easily work with thousand of servers in the cloud. Its programming model architecture allows you to work with sockets and network bandwidth traffic. It has less server load than any other technology available today (as of May 2013).


Now in this demonstration we will setup node.js under Debian / Ubuntu and it should also work under any Linux / Unix regardless apt-get installation setup.

Note: This has been tested under Ubuntu 10.04, 12.04.2 LTS and Debian 6.

Installing dependencies

Now the very first step is to install the dependencies which we require in further steps and will help us in the setup of node.js. Remember you need to run these commands as root, If you are not root then you need to be a sudo user which means a generic user being able to run commands root can. 

If you have just installed Ubuntu and during installation it asked for your username you can use that username and run commands by typing “sudo” before any command.

Now, let’s move back for installation of dependencies.

    sudo apt-get install g++ curl libssl-dev apache2-utils

    sudo apt-get install git-core


The first command is installing packages for compilation, SSL development packages and Apache2 Webserver utilities.

The second command is installing git-core utilities. This will help us download, update repositories from projects on git and the most famous code hosting “GitHub”

Now, we need to run below command which will clone / download code from node.js repository on GitHub

git clone git://


When the clone / download process is complete, there will be a directory called “node”. You will use the cd command which is for changing to a directory.

Command sequence

Please remember to follow the below commands sequence, read further and you will understand why.

We now use the command “./configure” which makes the system ready for compilation of the package and checks for necessary files and packages required for compilation and sets the environment for it.

“make” command compiles the package, In our case it is setting up node.js

“sudo make install” command runs as a super user which you may refer to it as root and install the files of node.js to the respective installation locations.

cd node



sudo make install


That’s it! You have installed node.js and it is setup.

If you don’t want to install git-core or download the repository from GitHub, You can also download the tarball archive by using below commands.


tar xvzf node-v0.1.96.tar.gz


Then you may use same commands as above by changing into directory and compilation.

Hello world!

Now, let’s check if our node.js that we just setup is working/

Use a traditional ‘hello world’ program to test if node.js is configured and installed properly.

We need to create a file having name anything you like, we are using filename “hello_world.js”

I use the command below to create it using my favorite Linux / UNIX editor called “vim”

vim hello_world.js


var http = require('http');

http.createServer(function (req, res) {

  res.writeHead(200, {'Content-Type': 'text/plain'});

  res.end('Hello Node.js\n');

}).listen(8124, "");

console.log('Server running at');


Now, execute the command “node” with sudo and give it the filename you just created with above test program.

sudo node hello_world.js


It should give you an output something like below.

Server running at

Now, you simply navigate to above output URL and see “Hello Node.js” message. This of course means node.js is setup and working. 

This article has been provided by Codero Hosting, the leading provider of reliable dedicated, managed and cloud hosting services. Need more information on this topic or to learn more about Codero’s hosting services please visit 
www.codero.comchat with us online or give us a call at 866-2-CODERO. 

Posted in
Last update:
2015-12-03 20:39
Average rating:0 (0 Votes)