How to Install Node.js on Debian 10 

Node.js, a JavaScript platform for programming, enables users to develop asynchronous web applications quickly. Users can use Javascript for both front-end and back-end programming. Learning how to install Node.js on Debian 10 is essential for every web developer.

Users can make web applications consistent and integrated by using Javascript for front-end and back-end development. The Node.js module is very helpful in this regard. In this tutorial, you will learn how to install Node.js on Debian 10 machines. You will also learn how to use various packages for Node.js installation. So let’s get started. 

1. Install the Official Node.js Package on Debian 10

The first method to install Node.js is from Debian’s default repositories. For this step, you will use the default Debian apt package manager. The default apt package manager consists of the Node.js version. 

Firstly, update the system’s existing packages using the apt get command. For example:

sudo apt-get update

Secondly, install the nodejs package using the apt install command. For example: 

sudo apt install nodejs npm
update apt packages

You will install the NPM package manager along with Node.js. To confirm the successful installation of Node.js, check its version using the -v or –version flag. For example:

node -v

2. Install Node.js Using PPA on Debian 10 

You can also install using PPA (Personal Package Manager) maintained by NodeSource. PPA is an alternate repository that also works in conjunction with apt. However, it consists of more updated versions. For this step, you will install PPA first. 

This will add the PPA to our default packages list and fetch the latest Node.js package using apt. Make sure to replace the x variable with the latest Node.js version.

curl -sL -o

Now, execute the sh file that you have downloaded using the curl command:

sudo bash

If the execution is successful, it will add PPA configuration in the apt package manager. Now, you can install it using the command we executed previously. For example:

sudo apt install nodejs

In addition, you will not have to install the NPM package manager. However, you will install the build-essentials package to make other NPM packages work properly. For this step, install build-essentials using the apt command. For example:

sudo apt install build-essential

Lastly, verify the installation using the -v or –version flag. 

3. Install Node.js Using NVM on Debian 10

The third alternative method to install Node.js is the NVM (Node Version Manager) package. NVM works as an independent directory within the user’s home directory. To elaborate further, it allows you to install multiple self-contained versions of Node.js in a single system. To download NVM from its GitHub repository, use the curl command. Make sure to change the version number. For example:

curl -sL -o

Secondly, run the bash script:


You will not need sudo access here because NVM works at the user level and does not require privileged directories. Next, find the Node.js version that you want to install using the ls-remote command. For example:

nvm ls-remote

Locate the required version and install it using the install command. For example:

nvm install 10.16.2

Lastly, verify the Node.js installation using the -v or –version flag.

node -v

4. Create a Demo Server 

Now that you have installed the latest Node.js version using any of the three methods. It is time to put it into action. In this step, you will test the Node.js installation by creating a web server with a simple JavaScript file. 

Firstly, create a sample file called http_server.js and open it using the nano or vim editor. For example: 

nano http_server.js 

Secondly, add the following content in the file:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello from\n');
}).listen(3000, "");
console.log('Server running at');
install Node.js on Debian

Let’s look at the code explanation. This script creates an HTTP object which requires an HTTP module. Secondly, it calls the createServer() method and passes the result as an argument. The “Content-type” explains the type of text that will be sent to the browser. The end() function contains the actual content. This code sends a simple “Hello World” text on the browser using the port 3000 via the default URL http://127.0.01

Next, start the node service using the node command, followed by the file name. For example:

node http_server.js 

You will see a similar output on the console:

install Node.js on Debian

Lastly, type the URL on the browser followed by the port number, and you will get the output on the screen.

5. Uninstall Node.js

You can easily uninstall Node.js from your Debian 10 machine using the apt or nvm command. To remove the package from apt, type the following command:

sudo apt remove nodejs

To remove the Node.js package that you installed using nvm, first find out whether you are using the current version or not. For example:

nvm current

Next, execute the following command to delete that version.

nvm uninstall node_version

This command will uninstall the selected version. However, you will have to deactivate the current version first if you are trying to uninstall that version. To deactivate, type the following command: 

nvm deactivate

Lastly, uninstall it using the uninstall command. For example:

nvm uninstall node_version

This will remove all the related files of the targeted Node.js version. 

Finally, you have learned how to install Node.js on Debian 10 machines in three different ways. You also learned how to create a web server and uninstalled the Node.js version. While installing from the Debian package manager is relatively easier, PPA and NVM packages offer greater flexibility. For more information on these packages, check out the official guide for PPA and NVM

If this guide helped you, please share it.

Leave a Reply
Related Posts