How to Install Node.js and NPM on Debian 11

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Installing Node.js and NPM on Debian 11 became so easier using Node Version Manager (NVM). This is a tool that can be installed per-user and invoked per-shell basis. You can install and switch between multiple Node.js versions easily.

In this guide you are going to learn how to install Node.js and NPM, manage multiple versions, uninstall versions using Node Version Manager.

Pre Installation Steps

Start by updating and upgrading the server packages to the latest version available.

sudo apt update
sudo apt dist-upgrade -y

Install NVM

You can copy the link for the latest NVM installation bash script directly from their official repository. The version available at the time of this article writing is v0.39.1.

Switch to the user on which you need to use Node.js.

sudo su username

Execute the following command to install NVM.

curl -o- | bash

This command downloads the installation script and runs it.

For the nvm command to be available you need to close the terminal and open again or you can simply execute the following command to make it available in your current session.

source ~/.bashrc

Verify the Installation

You can verify the installation using the below command.

command -v nvm


Install Node.js

You can check all available Node.js versions using the following command.

nvm ls-remote

. . .
v16.13.0   (LTS: Gallium)
v16.13.1   (LTS: Gallium)
v16.13.2   (Latest LTS: Gallium)
. . .

You can pick any specific version to install.

nvm install v16.13.2

This command installs Node.js and the related NPM.

Check Node.js version.

node -v


Manage Node.js versions using NVM

You can list all installed Node.js versions using the ls command.

nvm ls

You can install multiple Node.js versions using the install command.

You can switch between versions using the use command.

nvm use v14.18.3

You can uninstall a specific version using the uninstall command.

nvm uninstall v16.13.2

Become a Full-Stack Web Developer with React Specialization. Complete Web Development Course

Uninstall NVM

To remove nvm, execute the following:

$ rm -rf "$NVM_DIR"

Edit ~/.bashrc or other relevant shell resource config and remove the lines below.

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

That’s it. Now you have installed Node.js and NPM on Debian 11.


Now you have learned how to install, manage and uninstall Node.js on Debian 11 using NVM.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.