How to install and configure Node.js on Debian 9

How to install and configure Node.js on Debian 9


Node.js is a free, open-source JavaScript run-time environment designed to implement JavaScript code on the server-side via asynchronous programming. It is a cross-platform platform that makes it easy for administrators to develop network applications; create dynamic page content; collect form data; and add, modify, or delete data in the database.

This tutorial will help you install Node.js on your Debian 9 system using some popular technique; using an apt package manager, from the official NodeSource repository, and using the Node.js Version Manager (NVM).

Ready? Let’s get started!

Step 1 –
Installing Node.js Using An Package Manager

Debian’s default repository comes with a distro-stable Node.js version. The version is a stable option for a trial but may not be ideal for production and development uses cases. Nonetheless, if you feel this package suits your need, you can go ahead and install it.

In this section, we’ll utilize an apt package manager to install Node.js on Debian 9. First, execute the command below to update the package index:

$ sudo sudo apt update

Then, run the command to deploy the application (Node.js) from the Debian’s default repositories.

$ sudo apt install nodejs

Next, check the version of the Node.js application:

$ nodejs -v

Note: We are using Nodejs and not node to check the version of the newly installed Node.js. This prevents the conflict that may occur between the two executables from the official Debian repository.

If you are comfortable with the version you installed, then, that’s all you need to get started with Node.js on your Debian system. However, if you want to try other package archives, versions, and version managers, then, you will have to implement the most recent versions using the NVM or from the NodeSource repository.

Step 2 –
Installing Node.js Using A Personal Package Archive (PPA)

In this step, we’ll help you install Node.js using the personal package archive (PPA) which is maintained in the NodeSource repository. This will give you the flexibility to select the most recent Node.js versions including Node.js v4.x, Node.js v6.x, Node.js v8.x, and Node.js v10.x.

First, execute the commands below to update your package index:

$ sudo sudo apt update

Next, install curl; which help you access the NodeSource repositories.

$ sudo sudo apt install curl

Now, run the command below from the home directory to incorporate NodeSource repository into your Debian 9 system.

$cd ~
$ curl -sL -o

Here, you are using curl to get the required installation script for Node.js version 10.x. This is an ideal version to install since it’s supported until 2021. However, if you are not comfortable with this version, feel free to replace it with another one such as Node.js v8.x which is the latest LTS version.

To scrutinize the content of this installation script, execute the command below:

$ nano

Next, run the setup script using sudo:

$ sudo bash

Once that is done, you can now install Node.js:

$ sudo apt install nodejs

Now, execute the command below to check the version you have already installed:

$ nodejs -v

This will give you the output below:


Node.js package is complete and it comes with both nodejs binary and the Node.js Package Manager (NPM). For this reason, you don’t have to install NPM separately. Simply, run the command below to confirm if Node.js Package Manager is installed automatically:

$ npm -v

If npm was successfully installed, you will get the output below:


Next, you will have to install a build-essential application package to streamline the operation of some of the packages in npm.

$ sudo apt installbuild-essential

That’s it!

Step 3 –
Installing Node.js Using The NVM

If you are not comfortable with these two methods, you can try installing Node.js using the Node.js Version Manager. The NVM functions as a stand-alone directory of the home directory, giving you the freedom to implement numerous self-contained Node.js Versions. It gives you the option to work with the most recent Node.js versions and maintain older versions without impacting your system.

Note: The Debian versions you manage using NVM are different from the one managed using apt.

First, execute the command below to get the installation script for NVM from  GitHub page.

$ curl -sL -o

You can inspect this script using any text editor:

$ nano

Next, execute the installation script using bash:

$ bash

This will install Node.js into a unique subdirectory of the directory at ~/.nvm. Besides, it will incorporate the required lines into the ~/.profile file. Now, execute the command below to find the file  ~/.profile and enable the current session to recognize these changes:

$source ~/.profile

By now, the Node.js Version Manager is successfully installed and the stage is set for Node.js installation. But first, run the command below obtain a list of the available Node.js version;

$ nvm ls-remote

This will give you the output below:

         v8.11.1   (LatestLTS: Carbon)

Now, you can execute the command below to install v8.11.1; the current version for LTS.

$ nvm install 8.11.1

Next, run the command below to instruct nvm to utilize v8.11.1:

$ nvm use 8.11.1

You can use the command below to check the version being utilized by the current shell:

$ node -v

Note: The executable here is node and not the nodejs as used in the previous step. The command will give you the output:


If you already have multiple versions of Node.js installed on your system, you can execute the command below to get the list:

$ nvm ls

To make one of these versions such as v8.11.1your default applications:

$ nvm alias default 8.11.1

Next, you can direct nvm to use the default version everytime a session is opened:

$ nvm usedefault

Each Node.js version installed via nvm manages its unique packages and comes with a Package manager to maintain these packages.

You can instruct npm to install nvm packages on the directory ./node_modules, which is the official directory for Node.js projects. First, run the command below to install an  express module:

$ npm install express

If you wish to implement the express module globally and avail it to all projects using one Node.js version, simply add a -g to the command:

$ npm install -g express

The package will be installed in:


Next, run the command below to connect the express module to local sphere:

$ npm link express

If you need more details regarding nvm, run the command below to get help:

$ nvm help

Step 4 –
Uninstalling Node.js

The method you use to remove Node.js depends on your version of interest and the technique used to install it. Here, there are two options:

To remove a Node.js version implemented from the NodeSource repository, you will use an apt utility. Run the command below to uninstall Node.js using apt:

$ sudo apt remove nodejs

Alternatively, to uninstall Node.js version installed using the nvm follow the steps below:

  • First, execute the command below to check your current active Node.js version.
$ nvm current
  • To remove a Node.js version that is not currently active, execute the command below:
$ nvm uninstall node_version
  • Now, to remove the currently active Node.js version, first deactivate the nvm
$ nvm deactivate
  • Next, run an uninstall command to remove the files linked to the version of interest.


Congratulation! You have learned how to install and uninstall Node.js on your Debian system. The tutorial detailed three methods that can be utilized to install this application. The ball is in your court now! Evaluate your circumstance and go for the method that best suits your needs.

Check out these top 3 Node.js hosting services:

AU$4.47 /mo
Starting price
Visit Hostinger
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
AU$5.98 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
AU$2.68 /mo
Starting price
Visit FastComet
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
  • Want to get top recommendations about best hosting? Just click this link!

How To Install Node.js On Ubuntu 18.04

This tutorial will help you install the latest version of Node.js; a cross-platf
4 min read
David Malcom
David Malcom

How To Install Node.js on CentOS 7

This tutorial will help you install Node.js and the Node.js Package manager on C
4 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Install Node.js On Your Linux VPS or Dedicated Server

This tutorial walks you through the process of installing Node.JS on your Linux
2 min read
Lindsey Conger
Lindsey Conger

How to Create a Simple Web Server Using Node.js and Express

This tutorial shows you how to create a simple web server using Node.JS and Expr
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top