How to install and configure Node.js and npm in Ubuntu, Debian or Linux Mint

Node.js (and Above the sea level) is available in the official Debian, Ubuntu, and Linux Mint repositories, but some old versions may be updated depending on the version of the operating system you are using.

This article explains how to install and Above the sea level from the NodeSource repository and for setup Above the sea level so that you can use it to properly install Node.js packages globally in your home folder so that it doesn’t mess up permissions.

Install Node.js and npm from the Node.js repository in Debian, Ubuntu, and Linux Mint

An alternative way to install Node.js and manage multiple active versions is to use NVM Listen. These instructions use the officially Repository provided by Node.js instead.

These instructions are for:

  • Debian 8 (Jessie), Debian 9 (Stretch), Debian 10 (Buster), Debian Testing and Debian Unstable
  • Ubuntu 10/20, 04/20, 10/19, 04/18 LTS and 04/16 LTS
  • Linux Mint 20, 19 and 18
  • Raspberry Pi with Debian (Raspbian) or Ubuntu, with armhf (ARM 32-Bit-Hardfloat, ARMv7) or arm64 (ARM 64-Bit, ARMv8)
  • Other Linux distributions based on either the Debian or Ubuntu versions above


The node repository does not support ARMv6, therefore Raspberry Pi 1 is not supported.

1. Install Beckon (used to download the official Node.js installation script which will add the repository and key) and construction-essential (which are used to compile and install native addons):

sudo apt install curl build-essential

2. Run the Node.js installation script (provided by nodejs.org).

  • How to install Node.js LTS (current version 14):
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install nodejs

  • How to install Node.js Current (current version 16):
curl -sL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt install nodejs

  • To install Node.js 16:
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install nodejs

  • To install Node.js 15:
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt install nodejs

  • To install Node.js 12:
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install nodejs

  • To install Node.js 10:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs

the nodejs Contains package from the official NodeSource repository Above the sea level.

Configure npm to install packages globally without root

Using Above the sea level installed from either the Ubuntu repositories or the Node.js repository, requires running under root by default to install packages. This should be avoided as per many Articles on the Internet.

Receive Above the sea level to install packages globally in your home folder (and add the folder to your PATH), you can use a simple script available here. This script won’t work if you’re using NVM!

You can download the script and run it using these commands:

cd && wget https://raw.githubusercontent.com/glenpike/npm-g_nosudo/master/npm-g-nosudo.sh
chmod +x npm-g-nosudo.sh
./npm-g-nosudo.sh

After following the directions, get your .bashrc File:

. ~/.bashrc

Now you’re ready to install Above the sea level Packages globally without root / sudo, as follows:

npm install -g <some package>

The Node.js logo image is from Wikipedia.

Related Posts