Advance

How to install Node.js on Debian 10

How to install Node.js on Debian 10
0
(0)

What if a user needs to build asynchronous network applications quickly? In this tutorial, you will learn how to install Node.js on Debian 10. By this JavaScript platform, you can make web application development more consistent and integrated.

In this article, you will review how to get started with Node.js on Debian 10, installing Node from the default Debian repository by personal Package Archives repository, and using Node Version Manager to install and activate different versions of Node. And of course, we do not forget to show you how to uninstall these different versions of Node.

 

Prerequisites

The tutorial may be more useful if you know:

 

Recommended Article: CPanel and WHM installation tutorial on Linux and Virtual Server (VPS)

How to install Node.js on Debian 10

Let’s walk through the following steps to begin and finalize Node.js installation.

 

You may be interested in:

How to Install and config Node.js on Ubuntu 20.04

Installing the official Debian Node.js package

Since this version is 10.15.2 and the date of April 1, 2021, will be its life end, you will be no longer supported with security and bug fixes. As Debian contains a version of Node.js in its default repositories, you can install it from the Debian repo to make it sense. So to get Node.js from the default Debian software repository, you can use the apt package manager

To refresh your local package index, run the below command.

sudo apt update

Next, install the Node.js package, and npm the Node Package Manager:

sudo apt install nodejs npm  

You can check the installation process by running the node command with the -v flag to get the version.

node -v
Output
v10.15.2

Installing Using a PPA

If you want to work with an alternate repository, you can install from PPA (personal package archive) maintained by NodeSource. It still works with apt and will have more up-to-date versions of Node.js than the official Debian repositories. When you install PPA, this will add the repository to our package list and allow us to install the new packages using apt.

cd ~  curl -sL https://deb.nodesource.com/setup_12.x -o nodesource_setup.sh

Note: Ensure to replace 12.x with your preferred version string.

To verify the contents of this script with nano (or your preferred text editor) :

nano nodesource_setup.sh  

Then, run the script using sudo and exit your text editor.

sudo bash nodesource_setup.sh

Now you can install the nodejs package in the same way, as the PPA will be added to your configuration and your local package cache will be updated automatically.

sudo apt install nodejs

To verify the installation by running node with the -v version option, type:

node -v
Output

v12.8.0

Run the following command to verify that npm is installed and to create the configuration file:

npm -v
Output

6.10.2

Since you need the npm packages to work, you will need to install the build-essential package:

sudo apt install build-essential    

Buy Linux Virtual Private Server

 

Installing Using NVM

The other alternative to installing Node.js through apt is to use a tool called Node Version Manager (nvm). You can install multiple self-contained versions of Node.js without affecting the entire system. While you are controlling your environment with nvm, you are able to access the newest versions of Node.js while also retaining and managing previous releases.

Please note that the version number may differ from the highlighted below.

curl -sL https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh -o

To verify the installation script with nano:

install_nvm.sh

Then, run the script using bash and exit your text editor.

bash install_nvm.sh  

Now, you need to log out and log back in again or source the ~/.profile file to access the nvm functionality and let the session knows about the changes.

source ~/.profile  

Since the nvm is installed, you can install isolated Node.js versions, by typing the below command, you will get information about the versions of Node.js that are available.

nvm ls-remote

Output

. . .         v10.16.2   (Latest LTS: Dubnium)          v11.0.0          v11.1.0          v11.2.0          v11.3.0          v11.4.0          v11.5.0          v11.6.0          v11.7.0          v11.8.0          v11.9.0         v11.10.0         v11.10.1         v11.11.0         v11.12.0         v11.13.0         v11.14.0         v11.15.0          v12.0.0          v12.1.0          v12.2.0          v12.3.0          v12.3.1          v12.4.0          v12.5.0          v12.6.0          v12.7.0          v12.8.0

 

Then, install the latest version.

nvm install 10.16.2 

nvm, would use the most recently installed version by default. You can also tell nvm to use the version you just downloaded

nvm use 10.16.2

To verify the Node.js version currently being used or not, use the below command.

node -v
Output
v10.16.2

In case, you have multiple Node.js versions, you can see what is installed.

nvm ls

And if you want to default to a specific version.

nvm alias default 10.16.2

When a new session spawns, this version will be automatically selected.

nvm use default

Removing Node.js

Finally, it is time to learn how to remove versions installed from the Debian repository or from the PPA. Depending on the version you want to target, you can uninstall Node.js using apt or nvm. So you will need to work with the apt utility at the system level.

sudo apt remove nodejs

To continue, you need to determine the version you would like to remove is the currently active version or not, so, run the following command.

nvm current

If the currently active version and the version you are targeting are not the same, type

nvm uninstall node_version 

If the currently active version and the version you are targeting are the same, deactivate nvm to enable your changes.

nvm deactivate

 

In Conclusion

As you see, there are a few ways to get up and running with Node.js on your Debian 10 server. Depending on the circumstances, you can choose one of the methods you learned in this article. But installing from a PPA and working with npm or nvm offers additional flexibility.

Recommended Article: How to install Node.js on Debian 10

Dear user, we wish this tutorial would be helpful for you, to ask any question or review the conversation of our users about this article, please visit Ask page. Also to improve your knowledge, there are so many useful tutorials ready for Eldernode training.

 

Also, see

How to install MySQL on Debian 10

How to Install node.js on Windows

And

How To Install Node.js on CentOS 7

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day