How To Install Node.js on Debian 11

Node.js is becoming popular day by day and rightly so as it helps us, developers, in making server-side JavaScript applications. Node.js was first released in 2009 by Ryan Dahl and is based on the Google V8 JavaScript engine. As you can see, it’s only 11-12 years older but has made its name among the popular JavaScript run time environments out there.

Node.js specialty is that it is an open-source, free run time server environment that helps us in executing the JavaScript code outside the browser. Node.js is used for the backend as well as the front end by making a developer a full stack web developer. Hence it brings a level of consistency to our development.

Before going further, let’s explain what npm is? Npm full form is “Node Package Manager” and for node.js it is the default package repository.

Now that we have explained what Node.js and npm is, let us continue in this guide by helping you install Node.js. Node.js can be installed on any major OS like Windows, Mac OS, Linux distributions. In this article, we will provide a step-by-step guide and two basic methods to help you install Node.js on Debian 11. We will also show you how to uninstall Node.js from Debian 11.

1- Installation of Node.js on Debian 11

The first step in installing node.js on Debian 11 is to install the curl package. It is not available by default in Debian 11. To add Curl to our repository type the following command:

$ sudo apt install curl

For installing Node.js in Debian 11, type or copy the following command:

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

We can go ahead and install the latest version. However, let us see all the Node.js versions available in our Debian 11 system. For this purpose type the following command:

$ sudo apt policy nodejs

Now we can install the latest Node.js version by typing the following command in our terminal:

$ sudo apt install nodejs

To check whether the installation was successful or not we will type the following command in our terminal:

$ node -v

To check for the Npm version type the following command:

$ npm -v

Congratulations! You have installed Node.js on Debian 11.

Installation of Node.js on Debian 11 using Default Package

As mentioned earlier, Debian 11 contains the Node.js package by default. Installing Node.js through this method is extremely easy. However, this method is not recommended as the default version that comes with Debian 11 will be old.

The first step to install Node.js on Debian 11 using the Debian Node.js Package is to update the local packages by typing the following command in your terminal:

$ sudo apt update

After this we will install the Node.js package as well as the npm or node Package Manager using the following command:

$ sudo apt install nodejs npm

To verify the installation type the following command in your Debian 11 terminal:

$ node -v

Uninstallation/Removing of Debian 11

There may come a time where you will want to uninstall Node.js from your system. We can uninstall Node.js from your Debian system by using the apt package. Type the following command in your Debian 11 terminal to remove Node.js:

$ sudo apt remove nodejs

The above command will remove all the configuration files and the node.js package from your system.

Now when we check for the node.js or npm version we will get the following message:

$ node -v
$ npm -v

Conclusion

Node.js is the most advanced/groundbreaking technology out there for the developers of web applications right now. It was first released just about 11-12 years ago but is now leading in every aspect of server-side applications. To make it clear let me tell you that Netflix, PayPal is also developed using Node.js.

In this article, we saw how to install as well as uninstall Node.js on Debian 11. We hope that this guide would be enough in installing node.js in your Debian 11 system.

Subscribe to Our Newsletter
Join our Newsletter and get the latest Linux news and tips
in your inbox for FREE.