How to Install Node.js on Debian

Install Node.js on Debian 11, 12, or 13 with apt install nodejs npm, switch versions with nvm, or unpack official nodejs.org Linux binaries. Configure npm, create a package.json project, run scripts with node and npx, update, and uninstall without PATH conflicts.

Published

Updated

Read time 8 min read

Reviewed byDeepak Prasad

Install Node.js on Debian hero with DEBIAN GUIDE badge, Node.js runtime graphics, and npm project workflow highlights

Node.js is the JavaScript runtime used for web APIs, CLIs, build tools, and server-side apps. npm ships the default package manager and npx runner. Debian packages both in its main archive, but stable releases often trail the current Node.js LTSv24.18.0 (Krypton) at the time of writing—so many developers install apt for simplicity and add nvm or an official nodejs.org binary when a project needs a newer line.

This guide covers install Node.js on Debian for Debian 11 (Bullseye), 12 (Bookworm), and 13 (Trixie): install with apt, optionally enable backports, use nvm for version switching, unpack official Linux binaries, configure npm, scaffold a first project, update, and uninstall. I ran these steps on Debian 13 and kept real terminal output below.

Tested on: Debian 13 (trixie); kernel 6.12.94+deb13-amd64; amd64; Node 20.19.2 and npm 9.2.0 via apt; Node 24.18.0 and npm 11.16.0 via nvm.

IMPORTANT
Pick one system-wide Node provider (apt or a NodeSource .deb repo or an /opt tarball). nvm can coexist with apt because it only changes PATH for your user after you source ~/.nvm/nvm.sh—not for the whole OS.

Choose an install method

Method Best for Typical version (2026)
apt install nodejs npm Servers, CI, “just works” with Debian updates 20.x on trixie; 18.x on bookworm; 12.x on bullseye
nvm (nvm-sh/nvm) Developers switching versions per project Any release from nodejs.org/dist
Official Linux binary (nodejs.org) Fixed /opt or home-dir install without nvm Current LTS or Current release
NodeSource APT (distributions) System-wide newer Node via apt when nvm is not wanted Configurable major (documented on GitHub)

Most readers should start with apt when the Debian version matches project requirements. Add nvm when node -v is too old or you maintain apps on different majors.


Check your current Node.js

bash
. /etc/os-release && echo "$PRETTY_NAME"
node -v 2>/dev/null || echo "node: not installed"
nodejs -v 2>/dev/null || true
npm -v 2>/dev/null || echo "npm: not installed"
command -v node nodejs npm 2>/dev/null
apt-cache policy nodejs npm

On Debian 13:

text
Debian GNU/Linux 13 (trixie)
v20.19.2
v20.19.2
9.2.0
/usr/bin/node
/usr/bin/nodejs
/usr/bin/npm
nodejs:
  Installed: 20.19.2+dfsg-1+deb13u2
  Candidate: 20.19.2+dfsg-1+deb13u2

Debian provides nodejs as the package name; on current releases /usr/bin/node is the real binary and nodejs is a symlink. Both node and nodejs work.

Debian release Typical nodejs upstream Notes
Debian 13 (trixie) Node 20.19.x Install nodejs and npm
Debian 12 (bookworm) Node 18.20.x Still supported upstream LTS line
Debian 11 (bullseye) Node 12.22.x Far behind current LTS—use nvm or binary

Confirm package versions on packages.debian.org/nodejs for your suite.


Install the runtime and package manager from Debian’s archive:

bash
sudo apt update
sudo apt install -y nodejs npm

When packages are already current, apt reports:

text
nodejs is already the newest version (20.19.2+dfsg-1+deb13u2).
npm is already the newest version (9.2.0~ds1-3).

Verify:

bash
node -v
npm -v
dpkg -l nodejs npm
text
v20.19.2
9.2.0
ii  nodejs  20.19.2+dfsg-1+deb13u2  amd64  evented I/O for V8 javascript - runtime executable
ii  npm     9.2.0~ds1-3             all    package manager for Node.js

For native add-ons (packages that compile C++ bindings), install build tools once:

bash
sudo apt install -y build-essential python3

Prerequisites: sudo, apt, and outbound HTTPS to your Debian mirror.


Install a newer Node.js from backports (optional)

When backports carry a newer nodejs package for your stable release, enable the suite per Debian Backports — Instructions and the Debian Wiki — Backports.

Example for bookworm:

bash
echo 'deb http://deb.debian.org/debian bookworm-backports main' | \
  sudo tee /etc/apt/sources.list.d/bookworm-backports.list
sudo apt update
apt-cache policy nodejs

If a backports candidate appears:

bash
sudo apt install -y -t bookworm-backports nodejs
node -v

Search backports.debian.org first—Node.js is not always backported. When no entry exists, use nvm or an official nodejs.org binary.


Install Node.js with nvm (per-user versions)

nvm (Node Version Manager) installs Node under ~/.nvm/versions/ and is the most flexible way to run Node 24 LTS (or any other release) beside Debian’s apt package. Official installer: github.com/nvm-sh/nvm.

Install nvm (check the releases page for the current tag):

bash
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
# shellcheck source=/dev/null
. "$NVM_DIR/nvm.sh"

Install the current LTS from nodejs.org/dist:

bash
nvm install 24.18.0
nvm use 24.18.0
nvm alias default 24.18.0
node -v
npm -v
which node
text
Now using node v24.18.0 (npm v11.16.0)
v24.18.0
11.16.0
/root/.nvm/versions/node/v24.18.0/bin/node

Switch back to Debian’s package when needed:

bash
nvm use system
node -v
text
Now using system version of node: v20.19.2 (npm v9.2.0)
v20.19.2

Add the nvm.sh lines to ~/.bashrc or ~/.profile (the installer usually does this) so new shells load nvm automatically.

Project pinning: create a .nvmrc file in your repo:

bash
echo '24.18.0' > .nvmrc
nvm use

Install from the official Node.js Linux binary

nodejs.org publishes signed Linux x64 tarballs. Use this for a system-wide layout under /opt without nvm.

bash
NODE_VERSION=v24.18.0
ARCH=linux-x64
cd /tmp
curl -fsSLO "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-${ARCH}.tar.xz"
sudo mkdir -p /opt
sudo tar -xJf "node-${NODE_VERSION}-${ARCH}.tar.xz" -C /opt
sudo ln -sfn "/opt/node-${NODE_VERSION}-${ARCH}" /opt/node

Add to PATH for your user (~/.profile):

bash
export PATH="/opt/node/bin:$PATH"

Reload the shell, then verify:

bash
node -v
npm -v
text
v24.18.0
11.16.0

Verify downloads with the Node.js release signing procedure when your policy requires checksum or signature checks.


Install from NodeSource APT (system-wide alternative)

The NodeSource distributions project publishes deb.nodesource.com setup scripts for specific Node majors on Debian. Use this when you want apt upgrade to manage a newer system Node and nvm is not an option.

WARNING
Remove or avoid conflicting installs first. Do not stack NodeSource nodejs on top of Debian’s nodejs without planning which node binary should own /usr/bin/node.

Follow the README for your Debian major on github.com/nodesource/distributions—for example a setup_24.x script, then sudo apt install nodejs. NodeSource bundles npm with the nodejs package.


Configure npm

After any install method, confirm where npm puts global tools:

bash
npm config get prefix
npm config list -l | grep -E '^(prefix|cache|init)'

On a default apt install, prefix is often /usr/local. For user-local globals without sudo:

bash
mkdir -p ~/.local/bin
npm config set prefix "$HOME/.local"
grep -q '\.local/bin' ~/.profile || echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.profile
export PATH="$HOME/.local/bin:$PATH"

Set a default registry only when you use a mirror (corporate proxy or offline cache). The public default is https://registry.npmjs.org/.

Useful environment variables for apps:

Variable Purpose
NODE_ENV production disables some dev-only code paths in frameworks
NODE_OPTIONS Pass flags such as --max-old-space-size=4096 to every node process

Create your first Node.js project

Once node and npm work, scaffold a small project:

bash
mkdir -p /tmp/node-debian-demo && cd /tmp/node-debian-demo
npm init -y

Add a script and entry file:

bash
printf '%s\n' \
  "console.log('Node on Debian:', process.version);" \
  > index.js

Run directly:

bash
node index.js

Add an npm script in package.json (or edit by hand):

bash
npm pkg set scripts.start="node index.js"
npm run start
text
Node on Debian: v24.18.0

Install a dependency and run it with npx:

bash
npm install --save-exact [email protected]
npx cowsay "hello from Debian"
text
___________________
< hello from Debian >
 -------------------
        \   ^__^
         \  (oo)\_______

package.json and package-lock.json record exact versions—commit both for reproducible installs on other machines. For broader JavaScript patterns, see the Node.js tutorial.


Daily commands you will use

Task Command
Run a file node app.js
Install dependencies npm install (reads package.json)
Add a dependency npm install express
Run a package binary once npx eslint .
Update lockfile after edits npm install
Audit for known issues npm audit

If a project documents Corepack (packageManager field in package.json), enable it with corepack enable on Node builds that ship Corepack (included in official nodejs.org and nvm installs).


Update Node.js

Apt:

bash
sudo apt update
sudo apt install --only-upgrade nodejs npm

nvm:

bash
nvm install 24.18.0   # or nvm install --reinstall-packages-from=current node
nvm alias default 24.18.0

Official /opt tarball: download the newer version, extract to /opt/node-VERSION, update the /opt/node symlink and PATH if needed.


Uninstall Node.js

Apt packages:

bash
sudo apt remove nodejs npm
sudo apt autoremove
dpkg -l nodejs | grep '^ii' || echo 'apt nodejs is not installed'

nvm-managed versions:

bash
nvm deactivate 2>/dev/null || true
nvm uninstall 24.18.0
# Remove ~/.nvm entirely when finished with nvm

Official /opt install:

bash
sudo rm -rf /opt/node-v24.18.0-linux-x64 /opt/node
# Remove PATH lines from ~/.profile

User caches (~/.npm, ~/.cache/node-gyp) are safe to delete when reclaiming disk space.


Troubleshooting

Symptom Likely cause Fix
node: command not found Node not installed or nvm not loaded sudo apt install nodejs or source ~/.nvm/nvm.sh
node -v shows the wrong version PATH order or mixed installs command -v node; use nvm use or remove duplicate system installs
npm ERR! EACCES on global install Writing under /usr without root Use npm config set prefix ~/.local or nvm
gyp ERR! building a module Missing compiler toolchain sudo apt install build-essential python3
The following packages have unmet dependencies (NodeSource) Conflicting nodejs packages Remove one provider: sudo apt remove nodejs then retry
Old OpenSSL / crypto errors on bullseye Node 12 from apt is EOL Install modern Node with nvm or nodejs.org binary

For Git-based npm dependencies, install Git on Debian first.


References


Summary

Install Node.js on Debian with sudo apt install -y nodejs npm when the Debian version matches your apps—Node 20 on trixie, 18 on bookworm. When you need Node 24 LTS or multiple majors on one account, use nvm (nvm install 24.18.0) or unpack the official nodejs.org Linux tarball under /opt. Configure npm prefix to avoid sudo globals, run npm init and npm run start for your first project, and stick to one system-wide provider so command -v node stays predictable. Use backports or NodeSource only when you explicitly need a newer system package and have checked packages.debian.org and backports.debian.org first.


Frequently Asked Questions

1. How do I install Node.js on Debian?

Run sudo apt update && sudo apt install -y nodejs npm, then verify with node -v and npm -v. Debian ships Node.js in the main archive; on Trixie both node and nodejs resolve to the same binary.

2. What version of Node.js does Debian install?

It depends on the release. Debian 13 (trixie) ships Node 20.x, Debian 12 (bookworm) 18.x, and Debian 11 (bullseye) 12.x. Run apt-cache policy nodejs before installing. Current Node.js LTS is published on nodejs.org/en/download.

3. Should I use apt, nvm, or the official Node.js binary on Debian?

Use apt for system-wide installs with Debian security updates. Use nvm when you switch Node versions per project or need the latest LTS ahead of your release. Use the nodejs.org tarball when you want a fixed /opt layout without nvm.

4. Why is npm a separate package on Debian?

Debian splits nodejs and npm so minimal servers can install the runtime only. The nodejs package suggests npm—install both for typical JavaScript development. Node.js builds from nodejs.org and nvm include npm in the same distribution.

5. How do I install a specific Node.js version on Debian?

With nvm: nvm install 24.18.0 && nvm use 24.18.0. With apt, you get the version tied to your Debian release unless backports or NodeSource distributions provide a newer package for your suite.

6. Can I mix apt nodejs and nvm on the same Debian user?

Yes. nvm prepends ~/.nvm/versions to PATH when loaded. Run nvm use system to return to /usr/bin/node from apt. Avoid installing a second system-wide Node from NodeSource while apt nodejs is still installed unless you remove one first.

7. How do I fix EACCES errors when running npm install -g?

Do not use sudo npm install -g as your daily user. Prefer nvm, a nodejs.org install under your home directory, or configure npm prefix to ~/.local with export PATH="$HOME/.local/bin:$PATH".

8. How do I uninstall Node.js from Debian?

For apt: sudo apt remove nodejs npm. For nvm: nvm uninstall VERSION and remove ~/.nvm if finished. For /opt/node-* tarballs, delete the directory and remove PATH entries from ~/.profile.
Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on …