Install Node.js 17 & NPM on Debian 11 Bullseye - Step by step guide ?

Node.js is an open-source and cross platform JavaScript framework. JavaScript is a popular programming language for building web applications. Node.js allows frontend developers using JavaScript to build the backend without using a different programming language. NPM is a software package manager for NodeJS that allows developers to share useful JavaScript libraries and packages.

Here at LinuxAPT, we shall look into the different ways of installing Node.JS & NPM on Debian 11.


Different Options of installing Node.JS & NPM on Debian 11

  • Node.js & NPM installation from Debian repository.
  • Node.js & NPM installation from source.


1. Node.js & NPM installation from Debian repository

Node.js and npm are available in the default debian repositories. They can simply be installed with the commands:

$ sudo apt update

Using the APT package manager, install NodeJS and NPM:

$ sudo apt install nodejs npm

This install Node.JS alongside a bunch of libraries and dependencies. 


2. Node.js & NPM installation from source

You can build and compile Node.js from source. This is the best option if you wish to install a specific version of Node.js. Here, we are going to install Node.js from source. First, add the repository to Debian 11 with the command:

$ curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -

Here's an snippet of the output. The setup script add the GPG signing key and proceeds to create a sources list file for the Node.JS repository in the /etc/apt/sources.list file.

Then it updates the package index to sync with the newly appended Node.JS repository.

At the tail-end of the output, you are provided with the next steps to take – which is to install Node.JS and NPM.

So, go ahead and install Node.JS 17 and npm with the command:

$ sudo apt install nodejs

As before, this installs NodeJS alongside a bucketload of other libraries and dependencies. To confirm NodeJS is installed, run:

$ node —-version

Also, you can verify npm version:

$ npm —-version

If you are interested in installing Yarn package manager, first add the GPG key:

$ curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null

Then add the Yarn repository to the sources list file:

$ echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Finally, update the package index to refresh the repositories:

$ sudo apt-get update

Thereafter, as instructed, install Yarn using APT package manager:

$ sudo apt install yarn


How to Uninstall Node.JS & NPM from Debian 11 Bullseye ?

To remove Node.JS 17, use the following command:

$ sudo apt remove nodejs -y

Next, remove the repository for complete removal.

$ sudo rm /etc/apt/sources.list.d/nodesource.list


[Need help in fixing Debian System packages issues ? We can help you. ]

This article covers how to install Node.js 17 & NPM on Debian 11 Bullseye. Node.js is an open-source, cross-platform, back-end JavaScript runtime environment built on Chrome’s V8 engine to build fast and scalable network applications and back-end APIs. While NPM is a package manager for the JavaScript programming language maintained by NPM, Inc. NPM is the default package manager for the JavaScript runtime environment Node.js and is arguably the most available repository for Node.JS packages.

Related Posts