Debian

Install Node.js 17 & NPM on Debian 11 Bullseye

Install Node.js 17 & NPM on Debian 11 Bullseye

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.

In this guide you will learn how to install Node.JS & NPM on Debian 11.

Option 1: Install Node.js & NPM 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 as follows:

$ sudo apt install nodejs npm

This install Node.JS alongside a bunch of libraries and dependencies. This might take a while and it’s advisable that you have a good internet connection.

Option 2: Install Node.js 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. In this step 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 seup 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 as shown.

$ 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

Conclusion

This wraps up our guide. Have fun developing your applications with Node.JS

Similar Posts