How to Install Node.js on Debian 10

Install Node.js on Debian 10

In this article, we will have explained the necessary steps to install and configure Node.js on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Node.js is a cross-platform JavaScript run-time environment built on Chrome’s JavaScript designed to execute JavaScript code on the server-side. With Node.js, you can build scalable network applications. Node.js runs on Linux, Windows and macOS.

Install Node.js on Debian

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade

Step 2. Install Node.js on Debian 10.

  • Installing Node.js from the official Debian 10 package repository with the following command:
sudo apt install nodejs

One the installation is completed, verify it by typing:

# nodejs --version
v10.15.2
  • Installing Node.js and npm using NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

The installation script clones the nvm repository from Github to the ~/.nvm directory and adds the nvm path to your Bash or ZSH profile:

...
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Check nvm version and confirm installation typing:

node --version

Now install Node.js by using the following command:

nvm install node

Verify Node.js installation by typing:

node --version

Step 3. Uninstalling Node.js.

If for some reasons you want to uninstall Node.js and npm packages, use the following command:

sudo apt remove nodejs npm

Congratulation, you have learned how to install and configure Node.js on Debian 10 Buster. If you have any question, please leave a comment below.