How to Install NodeJS on Ubuntu / Debian / Linux Mint using PPA

Install NodeJS on Ubuntu / Debian / Linux Mint
Install NodeJS on Ubuntu / Debian / Linux Mint

Node.js is an open source, cross-platform JavaScript runtime environment for developing network tools and web applications. Many of Node.ja modules are written in JavaScript, which simplifies development of applications using Node.js. Node.js nothing but a combination of the Runtime environment and JavaScript modules.

Node.js interprets JavaScript using Google’s V8 JavaScript engine; it was developed by Ryan Dahl in 2009. This guide helps you to install Node.js on Ubuntu / Debian / Linux Mint operating systems.


The are two versions of Node.js is available for the users. Check out the official page to get the latest version of Node.js.

  • v4.5.0, Long Term Supported
  • v6.5.0, Current Latest Version

Supported Operating Systems:

Ubuntu versions:

  • Ubuntu 12.04 LTS (Precise Pangolin)
  • Ubuntu 14.04 LTS (Trusty Tahr)
  • Ubuntu 16.04 LTS (Xenial Xerus)

Debian versions:

  • Debian 7 (wheezy)
  • Debian 8 / stable (Jessie)

Linux Mint versions:

  • Linux Mint 13
  • Linux Mint 17
  • Linux Mint 17.1
  • Linux Mint 17.2
  • Linux Mint Debian Edition (LMDE) 2

Install Build Toos:

This step is optional: You may need to install build tools If you want to compile and install native add-ons from npm.

$ sudo apt-get install -y build-essential

Add Node.js PPA:

Node.js binary packages are maintained by NodeSource Debian and Ubuntu binary distributions repository (formerly Chris Lea’s Launchpad PPA). You can choose either one of the Node.js version to install on your machine.

### PPA for Node.js v4.x ###

curl -sL | sudo -E bash -

### PPA for Node.js v6.x ###

curl -sL | sudo -E bash -

### PPA for Node.js v7.x ###

curl -sL | sudo -E bash -
Debian Wheezy and Ubuntu Precise package is not available for Node.js v7.x, consider reading about running Node.js 4.x on older distros.
If you are planning to install Node.js v4.x on Ubuntu 12.04 or Debian 7, consider reading about running Node.js 4.x on older distros.

Install Node.js:

Once after adding the PPA on the server, install the Node.js by using the following command. NPM (Node Package Manager) will also be installed along with Node.js.

$ sudo apt-get install -y nodejs

Verify Node.js Installation:

Check the version of Node.js and NPM using the following command. The following output is for your informational, and it depends on the repository (v4.x or v6.x or v7.x) you chose to install.

$ nodejs -v

$ npm -v

Create Test Web Server:

If you want to test your Node.js installation, create a web server and run with Node.js.

Let’s create a file called “web_server.js

$ vi web_server.js

Place the below content into the web_server.js file.

const http = require('http');
const port = 8080;
const server = http.createServer((req, res) => {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello World\n');
server.listen(port, () => {
  console.log(`Server running at http://your-ip-add-ress:${port}/`);

Now, start the web server using the below command.

$ nodejs --debug web_server.js

You should get the following message on your terminal. This confirms the web server has been started and listening on port 8080.

Open your web browser and navigate it to the following web address.


You should get the web page like below.

Install NodeJS on Ubuntu using PPA
Install NodeJS on Ubuntu using PPA

That’s all. You have successfully installed Node.js on Ubuntu / Debian / Linux Mint.

Further Reading

You might also like