Installing Node JS on Ubuntu 16.04 LTS

Add NodeJS PPA

sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

2. Install nodejs

sudo apt-get install nodejs
Verify version
name@host:~$node -v
v6.8.0
name@host:~$npm -v
3.10.8

Optional – To test installation

Create a file server.js with the following contents

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Test Server');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:300');

Access localhost:3000 from the browser