The following two tabs change content below.
Hi, I have written and developed this site to share my experience and ideas with other colleagues. I also started to prepare interview questions and answers for job seekers. I hope it will help you a lot.

On Window System:

  1. Download Node.js on your system from according to your Operating System.
  2. After install set the path variable till \bin folder. In my case I have set like below:


3. Now for testing open command prompt (cmd) and create a file welcome.js on any specific location like:


4. Now for test the created program like:


5. If your program run without any error means all are set. And now you can start your development.


On Linux System: 

1. Download the binary node.js setup file “node-v0.12.0-linux-x86.tar.gz” on /tmp location and install Node.js like           below.

$sudo apt-get install nodejs

2. Now set the path variable like window using below command.

$export PATH=$PATH:/usr/local/nodejs/bin

3. After all these steps we can create a sample program to test the installation is done successfully or not.
4. Create a directory on any specific location like below:


5. Now create a Node.js program under this directory and test like below:



Node.js program for database connection and API

Download program file from here db_and_api and code also given here

//  Database and API code

var express = require(‘express’);
var app = express();
var mysql = require(‘mysql’);

var connectionpool = mysql.createPool(
host : ‘localhost’,
user : ‘root’,
password : ”,
database : ‘nodejs’,

//API and Query for getEmployeeDetail start
var query = ‘SELECT * FROM employee’;
var rows;
app.get(‘/getEmployeeDetail’, function (req, res) {
connectionpool.getConnection(function(err, connection) {
if (err) {
console.error(‘CONNECTION error: ‘,err);
res.statusCode = 503;
result: ‘error’,
err: err.code
} else {
connection.query(query, function(err, rows, fields) {
if (err) {
res.statusCode = 500;
result: ‘error’,
err: err.code
result: ‘success’,
err: ”,
json: rows,
length: rows.length
//getEmployeeDetail End

var server = app.listen(8081, function () {
var host = server.address().address
var port = server.address().port
console.log(“Server listening at http://%s:%s”, host, port)

Some screenshots are here:

Node.js server start



API access and output


733 total views, 2 views today

One thought on “How to install and setup the Node.js on window and Linux system”

Leave a Reply

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