Nodejs and NPM setup on Linux Mint 19

Node.js is a platform built on Chrome’s V8 JavaScript engine. Node.js can be used for easily building fast, scalable network applications. Here I will show you how to install latest Nodejs & NPM on Linux Mint 19 Tara

At the time of writing this story the latest version of Nodejs are

stable version(LTS) — 10.15.0 and current version(may be you can call beta version) — 11.6.0 It can be found on official site

Setup is a simple 5 step process -

Run below command to check if Node.js and NPM is installed or not

$ node -v
Command 'node' not found
$ npm -v
Command 'npm' not found

You need to setup Node.js PPA setup in your system. You can do that using below commands:

For LTS / stable version

$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

For Current version

$ curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -

Once Node.js PPA is setup successfully, run below command to install Node.js 10.x and npm

$ sudo apt-get install -y nodejs

After installation is completed successfully, its time to verify the version

$ node -v
v10.15.0
$ npm -v
6.4.1

Create a file and add below content to the file.

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

Start server using command:

$node hello_world.js
Server running at http://127.0.0.1:3001/

If you open url http://127.0.0.1:3001/ in browser, you will see message “Hello World…!!!”

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store