Step 1: Add PPA in System
First add node.js ppa in our system using following set of command. We also need to install python-software-properties package if not installed already.
$ sudo apt-get install python-software-properties
$ sudo apt-add-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-add-repository ppa:chris-lea/node.js
$ sudo apt-get update
without PPA in Terminal
sudo apt-get install nodejs
Step 2: Install Node.js and NPM
After adding required PPA file, lets install Nodejs package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.
$ sudo apt-get install nodejs
you will need to install the build-essentials package for NPM
$ sudo apt-get install build-essential
after do that install with below command
$ sudo apt-get install npm
Step 3: Check Node.js and NPM Version
$ node -v
$ npm -v
Step 4: Create Demo Web Server (Optional)
This is an optional step. If you want to test your node.js install. Lets create an web server with “Hello World!” text. Create a file http_server.js
$ vim http_server.js
and add following content
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(3001, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3001/');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(3001, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3001/');
Now start the web server using below command.
$ node --debug http_server.js
debugger listening on port 5858
Server running at http://127.0.0.1:3001/