Web development and Linux system administration.

To install Node.js manually on Debian and Ubuntu based Linux distributions we can use NodeSource binary distributions.

1. Add the NodeSource package signing key

$# Using curl
$curl -sSL | sudo apt-key add -
$# Or using wget
$wget --quiet -O - | sudo apt-key add -

2. Add the NodeSource APT repository

You have to choose which version of Node.js you want to install and then we need to create a file containing the APT repository at /etc/apt/sources.list.d.

For example this is for Debian 10 (Buster) and Node.js version 13:

deb buster main
deb-src buster main

The 2 things that you have to change are the following:

  • node_13.x: Node.js version (eg: node_12.x, node_14.x)
  • buster: Distribution codename

The NodeSource distributions repository shows how to do create this file:

$# Create a variable with the Node.js version that you want to install
$# eg: node_12.x, node_13.x, node_14.x
$# Create a variable with the codename of your distribution
$DISTRO="$(lsb_release -s -c)"
$# Then we create the nodesource.list file with the APT repository
$echo "deb$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
$echo "deb-src$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list

3. Install Node.js

$# Update the list of packages
$sudo apt-get update
$# Install Node.js
$sudo apt-get install nodejs

4. Verify the installation

$# Check the installed version
$node -v

5. Update npm

The npm version that comes with Node.js might be out of date, you can update it to the latest version:

$sudo npm i npm -g

This is one way of installing Node.js on Debian and Ubuntu based distributions, the downside is that you can't have multiple versions installed at the same time, but you can use a tool like nvm (Node Version Manager) to install and use multiple versions of Node.js.

© 2020 All rights reserved

Made with Gatsby and hosted on Netlify