Getting Start With NodeJS 101 – HelloWorld

In this blog post we will see how to begin with nodejs and writing your first application


Installing nodejs is quite easy, on windows directly download the the msi installed from

On Ubuntu, use your package manager


$ curl -sL | sudo bash -

$ sudo apt-get install -y nodejs

$ apt-get install -y build-essential


on centos


$ curl -sL | bash -

$ yum install -y nodejs

$ yum install gcc-c++ make


Only nodejs is installed write


$ node -v


on your command line and it should print out the version number. This means nodejs has been installed properly.

Your First NodeJS Application

Open your text edit and write

console.log('Hello World!'); //print on screen
process.exit(0); //exist the application

save the files as first.js

Next run


$ node first.js


This should output Hello World!, on your screen.

Nodejs is capable of running full javascript, so all if condition, for loops, variable same as javascript will work.

Another simple code would be

var i = 0;

NPM - Nodejs Package Manager

NPM is a nodejs command line tool which is used to install various libraries which are required by nodejs.

Install a module is very easy


npm install [packagename]


$ npm install async


The above installs async package.



  1. Write a code display current date in nodejs.

  2. Define a JSON Object and write a for loop display it.