Welcome to our guide on how to install Latest Node.js and NPM on Ubuntu & Debian Linux distributions. Node.js is a free and open source server-side programming language which runs on various platforms (Linux, Windows, Unix, macOS). Node.js is a JavaScript runtime built on Chrome’s V8 engine for building fast and scalable network applications.

install nodejs ubuntu 18.04 debian 9

Step 1: Add Node.js APT Repository

The most recent packages of Node.js are available on a APT repository. First, update your system and install some dependencies.

sudo apt-get update
sudo apt-get -y install curl dirmngr apt-transport-https lsb-release ca-certificates vim

If you want to know the latest release, check Node.js Releases page

Add Node.js None LTS repository

If you want to go with the latest upstream version, add APT for that version. E.g for Node.js 11.x. It will be added like this.

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

This is most fit for Development on your Local machine.

Add Node.js LTS repository

For production use, I recommend you do the installation of the latest LTS release. As of this article update, this is Node.js 10.x.

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

Step 2: Install Latest Node.js on Ubuntu / Debian

After adding the repository, proceed to install Node.js and NPM.

sudo apt-get -y install nodejs

You can also development tools to build native addons:

sudo apt-get install gcc g++ make

Confirm versions.

$ node --version

$ npm --version

Step 3: Install Yarn package manager ( Bonus and Optional)

If you need yarn package manager, install it by running:

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

Confirm installation.

$ yarn --version

Step 4: Test Node.js

Let’s create a simple Nodejs app as a test that Node.js is working.

mkdir /tmp/node-demo
cd /tmp/node-demo

initialize nodejs project with default package.json file:

$ npm init -y
Wrote to /tmp/node-demo/package.json:

  "name": "node-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "keywords": [],
  "author": "",
  "license": "ISC"

Create an index.js

vim index.js


const express = require('express');

const PORT = 8080;
const HOST = '';

const app = express();
app.get('/', (req, res) => {
  res.send('Hello Node.js World\n');

app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);

Install express package with npm command:

$ npm install -save express
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
added 48 packages from 36 contributors and audited 121 packages in 2.555s
found 0 vulnerabilities

Add start script to our packge.json file

"start": "node index.js"

You can now run Nodejs application:

$ node index.js 
Running on


$ npm start
Running on

The application can be started with debugging enabled using:

$ node --inspect index.js 
Debugger listening on ws://
For help, see: https://nodejs.org/en/docs/inspector
Running on

If you visit your Server IP on port 8080, you should see Node.js application output.

nodejs web application

There you go!. Node.js has been successful installed on Ubuntu / Debian Linux distribution. Have a happy Node Development.


Install PM2 Node.js Process Manager on RHEL / CentOS 8

How to Install Node.js 10 LTS on RHEL 8

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here