Debian

Install Node.js on Debian 13 / 12

Debian 13 (Trixie) ships Node.js 20 in its default repositories, which is fine for many use cases. But if you need the latest LTS (Node.js 22) or want to manage multiple versions, you have two other solid options: the NodeSource repository or NVM.

Original content from computingforgeeks.com - post 101

This guide covers all three methods on Debian 13 and Debian 12, with version numbers and outputs verified on real systems. Pick the method that fits your workflow.

Tested March 2026 | Debian 13.4 (Trixie), Node.js 20.19.2, 22.22.1, npm 9.2.0/10.9.7

Which Method Should You Use?

MethodBest forNode.js versionMulti-version support
Debian repos (apt)Servers, CI pipelines, minimal setup20.x (Debian 13), 18.x (Debian 12)No
NodeSourceGetting the latest LTS system-wide22.x, 20.x, 18.x (your choice)No
NVMDevelopers switching between projectsAny version, any timeYes

Method 1: Install from Debian Repositories

The simplest approach. Debian 13 includes Node.js 20 (LTS) in its repos:

sudo apt update
sudo apt install -y nodejs npm

Verify both were installed:

node --version
npm --version

On Debian 13, this gives you:

v20.19.2
9.2.0

On Debian 12, the repo ships Node.js 18.x. Both are LTS versions with long-term security patches from Debian’s maintainers. The trade-off is that repo versions lag behind upstream. If you need the cutting-edge features or a specific version, use NodeSource or NVM instead.

Method 2: Install from NodeSource (Latest LTS)

NodeSource maintains pre-built Node.js packages for Debian and Ubuntu. This gives you the latest upstream versions with proper deb packaging.

First, remove any existing Node.js from Debian repos to avoid conflicts:

sudo apt remove -y nodejs npm

Add the NodeSource repository for Node.js 22 (current LTS):

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

Install Node.js (npm is bundled with the NodeSource package):

sudo apt install -y nodejs

Check the versions:

node --version
npm --version

With NodeSource, you get the latest upstream builds:

v22.22.1
10.9.7

To install Node.js 20 instead of 22, replace setup_22.x with setup_20.x in the curl command. The NodeSource GitHub repo lists all available versions.

Method 3: Install with NVM (Multiple Versions)

NVM (Node Version Manager) lets you install and switch between any Node.js version instantly. This is the best option for developers working on multiple projects that target different Node.js versions.

Install NVM:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

Reload your shell to activate NVM:

source ~/.bashrc

Install the latest LTS version:

nvm install 22

NVM downloads, compiles (if needed), and switches to the version:

Checksums matched!
Now using node v22.22.2 (npm v10.9.7)

Install another version alongside it:

nvm install 20

Switch between versions any time:

nvm use 22
nvm use 20

List all installed versions:

nvm ls

The output shows all versions with an arrow pointing to the active one:

->     v20.20.2
       v22.22.2
         system
default -> 20 (-> v20.20.2)
lts/iron -> v20.20.2
lts/jod -> v22.22.2

Set a default version that loads automatically in new shells:

nvm alias default 22

NVM installs Node.js per-user under ~/.nvm/, so it doesn’t conflict with system packages. The downside is that NVM doesn’t work with sudo by default (the node binary isn’t in root’s PATH).

Test Node.js

Quick sanity check that Node.js runs correctly:

node -e 'console.log("Node.js " + process.version + " on " + process.platform)'

Expected output:

Node.js v22.22.1 on linux

Install a package globally to verify npm works:

npm install -g yarn

Uninstall Node.js

The removal process depends on how you installed it.

For apt-installed Node.js (Debian repos or NodeSource):

sudo apt remove -y nodejs
sudo rm -f /etc/apt/sources.list.d/nodesource.list

For NVM-installed versions:

nvm uninstall 22
nvm uninstall 20

To remove NVM itself, delete the directory and remove the loader lines from ~/.bashrc:

rm -rf ~/.nvm

Once Node.js is set up, you might want to look at hosting web applications with Nginx as a reverse proxy in front of your Node.js apps, or explore Docker on Debian for containerized deployments.

Related Articles

Ubuntu Switch Default Java Version on Ubuntu / Debian Debian How To Install Node.js 12 on Debian 11/10/9 Debian Install Vivaldi Web Browser on Ubuntu / Debian Linux Debian Install Opera Browser on Ubuntu 24.04 / Debian 13

Leave a Comment

Press ESC to close