← Back to Blog

Install Node.js on Debian 13 and Ubuntu 26.04 / 24.04: apt, NodeSource or nvm

Published · by Leo Gashi, RS Computers

Node.js Debian 13 Ubuntu

Debian 13 (trixie) installs Node.js 20 with apt install nodejs: on 3 December 2026 the exact package is 20.19.2+dfsg-1+deb13u3, and npm is a separate package, 9.2.0~ds1-3. Ubuntu 24.04 gives you Node.js 18 (18.19.1+dfsg-6ubuntu5) and Ubuntu 26.04 gives you Node.js 22 (22.22.1+dfsg+~cs22.19.15-1ubuntu1), while nodejs.org lists 26.14.0 as the Active LTS release on the same day.

So the distro package is one to three majors behind, and on Debian 13 and Ubuntu 24.04 it is a branch that nodejs.org has already marked end-of-life. This guide covers the three ways to install Node.js (distro package, NodeSource repository, nvm per user) and what comes after: npm without sudo, pnpm and yarn, a systemd service, a reverse proxy, moving between majors and the errors people paste into search. We ran every command on 3 December 2026 in fresh Debian 13.8, Ubuntu 26.04.1 and Ubuntu 24.04.5 containers. RS Computers runs KVM servers in Amsterdam, Dublin and Prishtina, and any of our VPS and VDS plans comes with Debian 13 or Ubuntu and full root, so you can follow along on a clean server.

Quick answer

For a production app, add the NodeSource repository and install the Active LTS, as root:

apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_26.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt-get install -y nodejs
node -v && npm -v

Our Debian 13 lab answered v26.14.0 and 11.21.3. For a developer account that needs several versions, use nvm instead.

Key facts, checked on 3 December 2026:

Which Node.js version do Debian 13 and Ubuntu ship?

Ask apt on the server. This only reads package lists, so it is safe on a live machine. As root, or with sudo in front:

# as root
apt update
apt policy nodejs npm

Debian 13.8 answered:

nodejs:
  Installed: (none)
  Candidate: 20.19.2+dfsg-1+deb13u3
  Version table:
     20.19.2+dfsg-1+deb13u3 500
        500 http://deb.debian.org/debian trixie/main amd64 Packages
        500 http://deb.debian.org/debian-security trixie-security/main amd64 Packages
npm:
  Installed: (none)
  Candidate: 9.2.0~ds1-3
  Version table:
     9.2.0~ds1-3 500
        500 http://deb.debian.org/debian trixie/main amd64 Packages

In that string 20.19.2 is the Node.js release and +deb13u3 marks the third update built for Debian 13.

Release (tested)nodejs packagenpm packageUpstream status of that majorNodeSource 26.x
Debian 13.8 trixie20.19.2+dfsg-1+deb13u3 (main and trixie-security)9.2.0~ds1-3Node 20: end-of-life since 30 Apr 202626.14.0-1nodesource1, installed fine
Ubuntu 24.04.5 noble18.19.1+dfsg-6ubuntu5 (universe)9.2.0~ds1-2Node 18: end-of-life since 30 Apr 202526.14.0-1nodesource1, installed fine
Ubuntu 26.04.1 resolute22.22.1+dfsg+~cs22.19.15-1ubuntu1 (universe)9.2.0~ds3-1Node 22: Maintenance LTS until 30 Apr 202726.14.0-1nodesource1, installed fine
nodejs.org today26.14.0 (Active LTS), 24.23.0, 22.23.511.21.3 with 26 and 2427 is Alpha, no Current line-

Three ways to install Node.js, and when to use each

Distro packageNodeSource repositorynvm (per user)
Version you get today20 on Debian 13, 18 on Ubuntu 24.04, 22 on Ubuntu 26.04the major you pick: 26.14.0 or 24.23.0 in our labany, several side by side
Where node lives/usr/bin/node/usr/bin/node~/.nvm/versions/node/v26.14.0/bin/node
npm includedno, separate npm package (9.2.0)yes (11.21.3)yes (11.21.3)
Updatesapt upgrade, same major for the life of the releaseapt upgrade inside the majorby hand: nvm install
Needs rootyesyesno
Use it fortools packaged by the distro that depend on itservers and systemd servicesdevelopment, CI users, testing a new major

Route 1: install Node.js from the Debian 13 or Ubuntu repository

# as root
apt install -y nodejs
node -v
npm -v

On Debian 13 this set up 14 packages and printed:

v20.19.2
bash: line 5: npm: command not found

That is not a broken install. The nodejs package only lists npm under "Suggests", so apt does not pull it in. Corepack does come along on Debian 13 and Ubuntu 26.04 (node-corepack 0.24.0); the Ubuntu 24.04 package has neither npm nor corepack. Add npm by name:

# as root
apt install -y npm
npm -v

Be ready for the size. On Debian 13 apt reported 587 newly installed, Need to get 196 MB of archives and 883 MB of additional disk space, because Debian packages npm's dependencies as separate node-* packages and recommends a lot more on top. The answer at the end was 9.2.0. On Ubuntu 26.04 we measured the lighter variant: apt-get install -y --no-install-recommends npm came to 341 packages and 118 MB instead of 599 packages.

If your own app is the reason you are installing Node.js, skip to route 2: npm 9.2.0 on an end-of-life Node.js is where the errors further down come from.

Route 2: install Node.js 26 or 24 from NodeSource

NodeSource publishes apt repositories per Node.js major. Does it support Debian 13 and Ubuntu 26.04? Its supported versions table on 3 December 2026 still stops at Debian 12 Bookworm, Ubuntu 24.04 Noble and Node 24, so neither trixie nor 26.04 is listed. The setup script itself does not check the release, though: it writes one repository with Suites: nodistro for amd64 or arm64. In our lab it installed and ran on Debian 13.8, Ubuntu 26.04.1 and Ubuntu 24.04.5.

Download the script, read it, then run it. As root:

# as root
apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_26.x -o nodesource_setup.sh
less nodesource_setup.sh
bash nodesource_setup.sh
apt policy nodejs | head -4
apt-get install -y nodejs
node -v
npm -v

For Node.js 24 use setup_24.x. setup_lts.x pointed at 26.x today. On Debian 13 with the 24.x script, apt showed the candidate 24.23.0-1nodesource1 at priority 600, above Debian's 20.19.2+dfsg-1+deb13u3 at 500. The script creates that pin itself in /etc/apt/preferences.d/nodejs, next to /etc/apt/sources.list.d/nodesource.sources. The install is one package:

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Setting up nodejs (24.23.0-1nodesource1) ...
v24.23.0
11.21.3

NodeSource's nodejs package carries npm and npx inside it and declares Conflicts: npm. So never run apt install npm next to it, and expect apt to remove the distro npm if it was there. On Ubuntu 26.04, where we had installed Ubuntu's nodejs and npm first, the switch to NodeSource printed 1 upgraded, 0 newly installed, 115 to remove and left 248 more packages for apt autoremove. Read that removal list before you confirm on a server that runs other software.

Route 3: install Node.js with nvm for one user

nvm downloads official Node.js builds into your home folder. No root is needed and each user can hold several versions. The current release is v0.41.0. Log in as the user that will run Node.js, not as root:

# as your normal user
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm install 24
nvm alias default 'lts/*'
nvm use default
node -v && npm -v && which node
Now using node v26.14.0 (npm v11.21.3)
Creating default alias: default -> lts/* (-> v26.14.0 *)
...
v26.14.0
11.21.3
/home/deploy/.nvm/versions/node/v26.14.0/bin/node

Switch with nvm use 24, or put the major in a .nvmrc file in the project and run nvm use there. fnm is a similar per-user manager; we did not test it.

The price of nvm is that node only exists in interactive shells of that one user. Scripts, su -c, cron and systemd do not see it, which is the third error below.

npm, corepack, pnpm and yarn

npm comes with NodeSource and nvm builds. pnpm and yarn used to arrive through Corepack, a small shim that downloads the package manager a project asks for. On Node.js 24 that still works. As root on our NodeSource 24 install:

# as root, Node.js 24 and older
corepack enable
ls -l /usr/bin/pnpm /usr/bin/yarn
lrwxrwxrwx 1 root root 41 Dec  3 09:55 /usr/bin/pnpm -> ../lib/node_modules/corepack/dist/pnpm.js
lrwxrwxrwx 1 root root 41 Dec  3 09:55 /usr/bin/yarn -> ../lib/node_modules/corepack/dist/yarn.js

Node.js 26 has no corepack. After we upgraded that same machine from 24 to 26, which corepack returned nothing and both symlinks pointed at files that no longer existed, so yarn -v failed with -bash: line 1: /usr/bin/yarn: No such file or directory. Bringing Corepack back as a normal global package fixed it:

# as root
npm install -g corepack
corepack --version        # 0.36.0
yarn -v                   # 1.22.22

The other way is to skip Corepack and install the manager itself with npm install -g pnpm, which gave us pnpm 12.25.1 under nvm. With npm 11.21.3 that install ends with a new kind of notice: npm warn install-scripts 1 package has install scripts not yet covered by allowScripts. pnpm still reported its version; the message names the way to allow the scripts, npm install -g --allow-scripts=pnpm.

Install global packages without sudo

With a system-wide Node.js, npm install -g writes under /usr, which a normal user cannot do. Do not answer that with sudo npm install -g: package install scripts would then run as root. Give npm a folder in your home instead, which is also the manual fix in the npm documentation:

# as your normal user
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH=$HOME/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profile
npm install -g pnpm
which pnpm

Ours printed added 3 packages in 3s and /home/deploy/.npm-global/bin/pnpm. The setting is one line in ~/.npmrc. With nvm you do not need it: there npm config get prefix already printed /home/deploy/.nvm/versions/node/v26.14.0.

Run a Node.js app as a systemd service

A server app should start at boot, restart after a crash and run as its own user. This is the unit we tested, with a system-wide Node.js from route 1 or 2 and an app in /srv/hello listening on 127.0.0.1:3000. As root:

# as root
useradd --system --home-dir /srv/hello --shell /usr/sbin/nologin nodeapp
chown -R nodeapp:nodeapp /srv/hello
cat > /etc/systemd/system/hello.service <<'EOF'
[Unit]
Description=Hello Node.js app
After=network-online.target
Wants=network-online.target

[Service]
User=nodeapp
Group=nodeapp
WorkingDirectory=/srv/hello
Environment=NODE_ENV=production
Environment=HOST=127.0.0.1
Environment=PORT=3000
ExecStart=/usr/bin/node server.js
Restart=on-failure
RestartSec=3
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true

[Install]
WantedBy=multi-user.target
EOF
systemd-analyze verify /etc/systemd/system/hello.service
systemctl daemon-reload
systemctl enable --now hello
systemctl is-active hello
curl -s http://127.0.0.1:3000/

systemd-analyze verify printed nothing, which means no mistakes, and the app answered Hello from Node.js v20.19.2, pid 8111. Then we killed it with kill -9. The journal (journalctl -u hello) shows what the unit did about it:

hello.service: Main process exited, code=killed, status=9/KILL
hello.service: Failed with result 'signal'.
hello.service: Scheduled restart job, restart counter is at 1.
Started hello.service - Hello Node.js app.
listening on http://127.0.0.1:3000

A few seconds later it answered again with a new pid. ProtectSystem=strict makes the file system read-only for the app; an app that writes files needs a ReadWritePaths= line (systemd.exec), which ours did not. The same unit kept working after we replaced Debian's Node.js 20 with NodeSource 24 and then 26, because the path stays /usr/bin/node; only a systemctl restart hello was needed.

With nvm the unit needs changes. Pointing ExecStart at /home/deploy/.nvm/versions/node/v26.14.0/bin/node failed with status=203/EXEC, first "No such file or directory" because ProtectHome=true hides /home, then "Permission denied" because /home/deploy is mode 700 and the service ran as another user. It started only with User=deploy, ProtectHome=read-only and the app inside that home. That path also changes with every Node.js update, so for services we prefer route 2.

PM2 is the other common answer. Version 7.1.3 installed with npm install -g pm2 in our lab, pm2 start server.js --name hello2 showed the app as online, and pm2 startup printed a sudo env PATH=... pm2 startup systemd -u deploy --hp /home/deploy command to run once (PM2 startup docs). So PM2 hooks into systemd as well. For one app, the unit above has fewer moving parts.

Put the app behind a reverse proxy

Keep the app on 127.0.0.1 and let a web server take ports 80 and 443. This Nginx site (nginx 1.26.3 from Debian 13) passed our test with plain HTTP requests; the last two header lines are the usual ones for WebSocket upgrades:

server {
    listen 80;
    server_name app.example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

curl -s -H "Host: app.example.com" http://127.0.0.1/ returned the app's hello line through Nginx. When we stopped the service, the same request returned 502, which is the first thing to remember when a Node.js site shows 502 Bad Gateway: check systemctl status of the app before touching Nginx. HTTPS and the choice of proxy are covered in our Caddy, Nginx and Traefik comparison. Before the server goes public, lock down SSH and the firewall with the Debian 13 hardening steps or the Ubuntu version.

Upgrade Node.js between major versions

NodeSource: run the setup script of the new major and install again. We went from 24 to 26 on Debian 13, as root:

# as root
curl -fsSL https://deb.nodesource.com/setup_26.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt-get install -y nodejs
node -v
systemctl restart hello
Unpacking nodejs (26.14.0-1nodesource1) over (24.23.0-1nodesource1) ...
Setting up nodejs (26.14.0-1nodesource1) ...
v26.14.0

Restart your services afterwards, and after a jump to 25 or newer check pnpm and yarn as described above.

nvm: install the new major and carry your global packages over, then move the default:

# as your normal user
nvm install 26 --reinstall-packages-from=24
nvm alias default 26

We ran it in the other direction (nvm install 24 --reinstall-packages-from=26) and pnpm 12.25.1 appeared in the 24 tree.

Back to the distro package: apt-get purge nodejs, delete /etc/apt/sources.list.d/nodesource.sources and /etc/apt/preferences.d/nodejs, then run apt-get update; after that apt offered Debian's 20.19.2 again. apt does not track what npm install -g wrote: after our purge, /usr/lib/node_modules/corepack and the two symlinks were still there and had to be removed by hand.

Errors you will meet, with the exact text

bash: npm: command not found

You installed the distro nodejs package, which does not include npm on Debian 13, Ubuntu 24.04 or Ubuntu 26.04. Run apt install npm, or move to NodeSource or nvm, where npm is included.

npm error code EACCES ... permission denied, mkdir '/usr/lib/node_modules/serve'

A normal user ran npm install -g against a system-wide Node.js. With npm 11 from NodeSource:

npm error code EACCES
npm error syscall mkdir
npm error path /usr/lib/node_modules/serve
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/serve'
...
npm error The operation was rejected by your operating system.

With Debian's npm 9.2.0 the lines start with npm ERR! and the path is /usr/local/lib/node_modules. The fix is the same in both cases: the ~/.npm-global prefix from the section above, not sudo.

bash: line 1: node: command not found (after installing nvm)

nvm loads from the last lines of ~/.bashrc, and on Debian that file starts with a guard that returns at once for non-interactive shells. In our Debian 13 lab su - deploy -c 'node -v' and even bash -lc "node -v" both ended in node: command not found, while a shell that had loaded nvm worked. Cron jobs do not read your .bashrc either (our crontab guide explains the environment cron gives a job). Two things that worked:

# load nvm inside the command
bash -c 'source ~/.nvm/nvm.sh && node -v'

# or call the binary by its full path (print it with: nvm which default)
~/.nvm/versions/node/v26.14.0/bin/node -v

npm WARN EBADENGINE Unsupported engine

A package declares a newer Node.js than you run. On Debian 13's Node.js 20:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'corepack@0.36.0',
npm WARN EBADENGINE   required: { node: '^22.22.2 || ^24.15.0 || >=26.0.0' },
npm WARN EBADENGINE   current: { node: 'v20.19.2', npm: '9.2.0' }
npm WARN EBADENGINE }

It is a warning, so npm carries on. The fix is a newer Node.js, not --force. Today's releases of npm itself, Angular CLI and Corepack all asked for 22.22, 24.15 or 26, and n8n asked for >=24.0.0 (from npm view n8n engines.node); if n8n is your goal, start from our n8n self-hosting guide.

npm ERR! code EBADENGINE ... Not compatible with your version of node/npm: npm@12.2.3

The hard form of the same problem. The usual trigger is "just update npm" on a distro install:

$ npm install -g npm@latest
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: npm@12.2.3
npm ERR! notsup Required: {"node":"^22.22.2 || ^24.15.0 || >=26.0.0"}
npm ERR! notsup Actual:   {"npm":"9.2.0"}

npm refused and stayed on 9.2.0. Install Node.js 24 or 26 through route 2 or 3 and the matching npm comes with it.

node -v shows v18 or v20 after installing NodeSource

Run apt policy nodejs. The NodeSource version must be the candidate, at priority 600. If only the distro version appears, the setup script did not finish: look for /etc/apt/sources.list.d/nodesource.sources and run apt-get update. If apt shows the right version and another number still prints, run which node: a shell with nvm loaded uses the copy under ~/.nvm, not /usr/bin/node.

How we tested

All tests ran on 3 December 2026 in fresh system containers with 2 GiB of memory on one of our lab hosts: Debian 13.8, then Ubuntu 26.04.1 LTS, then Ubuntu 24.04.5 LTS, one at a time. On Debian we went through all three routes, the global prefix, the systemd unit with a crash test, Nginx 1.26.3 as proxy, the NodeSource 24 to 26 upgrade, nvm 0.41.0 with Node.js 26.14.0 and 24.23.0, and PM2 7.1.3. On both Ubuntu releases we read apt policy, installed the distro package and then NodeSource 26.x; on 24.04 also nvm. Every version string and error text here is copied from those sessions; release dates and support windows come from nodejs.org on the same day.

What we did not test

Frequently asked questions

What Node.js version does Debian 13 have?

Node.js 20. On 3 December 2026 the package is nodejs 20.19.2+dfsg-1+deb13u3, present in trixie main and trixie-security, and npm is a separate package at 9.2.0~ds1-3. Node.js 20 has been end-of-life upstream since 30 April 2026, so fixes for it now come from Debian, not from nodejs.org.

What Node.js version do Ubuntu 24.04 and 26.04 have?

Ubuntu 24.04 has Node.js 18 (18.19.1+dfsg-6ubuntu5) and Ubuntu 26.04 has Node.js 22 (22.22.1+dfsg+~cs22.19.15-1ubuntu1). Both come from the universe component, and on both npm is a separate package at version 9.2.0.

How do I install Node.js 24 on Debian 13?

As root, download https://deb.nodesource.com/setup_24.x, run it with bash, then apt-get install -y nodejs. In our Debian 13 lab that installed 24.23.0-1nodesource1 with npm 11.21.3. With nvm, nvm install 24 gave the same 24.23.0 for one user.

Does NodeSource support Debian 13 trixie and Ubuntu 26.04?

Its published table on 3 December 2026 lists Debian up to 12 and Ubuntu up to 24.04, so not officially. The setup script uses one "nodistro" repository and does not check the release; Node.js 26.14.0 installed and ran on Debian 13.8, Ubuntu 26.04.1 and Ubuntu 24.04.5 in our tests.

Should I use Node.js 24 or 26 in production?

Both are LTS lines. Node.js 26 is the Active LTS and is supported until 30 April 2029; Node.js 24 is in Maintenance and ends on 30 April 2028. Start new projects on 26 unless a dependency still asks for 24; note that 26 no longer ships Corepack.

nvm or NodeSource on a server?

NodeSource for anything that runs as a service: the binary is /usr/bin/node for every user and apt updates it. nvm for developer and CI accounts that need several versions.

Setting up PHP on the same server? See PHP on Debian 13 and PHP on Ubuntu 26.04 and 24.04.

Sources

Need a hand?

A small API or a staging app runs well on a VPS with NVMe in Amsterdam, Dublin or Prishtina, ready with Debian 13 or Ubuntu in under 60 seconds after payment. Busy apps that run several worker processes or heavy builds are better on a VDS with dedicated vCPU, where the cores are not shared. If you would rather have it built for you, from the service units and the proxy to a deploy script, we do custom offers, custom setups and systems built for you, quoted per job: message us on Telegram or write to info@rscomputers-ks.com.

← All articles

Chat on Telegram