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 -
1. Check if Node.js and NPM installed
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
2. Configure Node.js PPA
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 -
3. Install Node.js
Once Node.js PPA is setup successfully, run below command to install Node.js 10.x and npm
$ sudo apt-get install -y nodejs
4. Verify Node.js and NPM Version
After installation is completed successfully, its time to verify the version
$ node -v
v10.15.0$ npm -v
6.4.1
5. Verify Node.js installation
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…!!!”