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 LTS—v24.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.
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
. /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 npmOn Debian 13:
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+deb13u2Debian 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 Node.js with apt (recommended)
Install the runtime and package manager from Debian’s archive:
sudo apt update
sudo apt install -y nodejs npmWhen packages are already current, apt reports:
nodejs is already the newest version (20.19.2+dfsg-1+deb13u2).
npm is already the newest version (9.2.0~ds1-3).Verify:
node -v
npm -v
dpkg -l nodejs npmv20.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.jsFor native add-ons (packages that compile C++ bindings), install build tools once:
sudo apt install -y build-essential python3Prerequisites: 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:
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 nodejsIf a backports candidate appears:
sudo apt install -y -t bookworm-backports nodejs
node -vSearch 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):
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:
nvm install 24.18.0
nvm use 24.18.0
nvm alias default 24.18.0
node -v
npm -v
which nodeNow using node v24.18.0 (npm v11.16.0)
v24.18.0
11.16.0
/root/.nvm/versions/node/v24.18.0/bin/nodeSwitch back to Debian’s package when needed:
nvm use system
node -vNow using system version of node: v20.19.2 (npm v9.2.0)
v20.19.2Add 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:
echo '24.18.0' > .nvmrc
nvm useInstall 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.
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/nodeAdd to PATH for your user (~/.profile):
export PATH="/opt/node/bin:$PATH"Reload the shell, then verify:
node -v
npm -vv24.18.0
11.16.0Verify 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.
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:
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:
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:
mkdir -p /tmp/node-debian-demo && cd /tmp/node-debian-demo
npm init -yAdd a script and entry file:
printf '%s\n' \
"console.log('Node on Debian:', process.version);" \
> index.jsRun directly:
node index.jsAdd an npm script in package.json (or edit by hand):
npm pkg set scripts.start="node index.js"
npm run startNode on Debian: v24.18.0Install a dependency and run it with npx:
npm install --save-exact [email protected]
npx cowsay "hello from Debian"___________________
< 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:
sudo apt update
sudo apt install --only-upgrade nodejs npmnvm:
nvm install 24.18.0 # or nvm install --reinstall-packages-from=current node
nvm alias default 24.18.0Official /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:
sudo apt remove nodejs npm
sudo apt autoremove
dpkg -l nodejs | grep '^ii' || echo 'apt nodejs is not installed'nvm-managed versions:
nvm deactivate 2>/dev/null || true
nvm uninstall 24.18.0
# Remove ~/.nvm entirely when finished with nvmOfficial /opt install:
sudo rm -rf /opt/node-v24.18.0-linux-x64 /opt/node
# Remove PATH lines from ~/.profileUser 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
- Node.js — Download
- Node.js — Distribution directory
- Node.js — Verifying binaries
- packages.debian.org — nodejs
- Debian Wiki — Backports
- Debian Backports — Instructions
- nvm — GitHub repository
- NodeSource distributions — GitHub
- npm — Documentation
- On-site: Node.js tutorial, install Git on Debian, apt command, curl command
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.

