How to Install Node.js on Debian 13, 12 and 11

Last updated Tuesday, May 19, 2026 10:16 am Joshua James 9 min read

Debian ships a stable but older Node.js in its default repositories, which works for basic server tasks but falls behind what many JavaScript projects expect. To install Node.js on Debian, choose between Debian’s own packages, a newer NodeSource stream through extrepo, or NVM when each project needs its own runtime version.

Debian 13 ships Node.js 20.19.x, Debian 12 ships 18.20.x, and Debian 11 ships 12.22.x in default repositories. NodeSource through extrepo on Debian keeps updates APT-managed while offering newer streams such as 24.x LTS, and NVM handles per-project version switching entirely from your home directory.

Install Node.js on Debian

Use one of the following methods and keep the same method for updates and removal. Mixing APT sources, NVM-managed paths, and custom npm prefixes is the most common cause of confusing Node.js behavior.

Choose the Node.js Installation Method

Use this comparison to pick the package source that matches your workflow:

MethodChannelVersionUpdatesBest For
Debian RepositoriesDebian PackagesDebian 13: 20.19.x, Debian 12: 18.20.x, Debian 11: 12.22.xAutomatic via apt upgradeStable server and workstation installs that prioritize Debian packages
NodeSource via extrepoNodeSource24.x Active LTS, 22.x Maintenance LTS, and other streams exposed by extrepo dataAutomatic via apt upgradeDevelopers who need a newer APT-managed Node.js than Debian defaults
Node Version Manager (NVM)NVMAny supported Node.js versionManual via nvm installPer-project version switching and local dev workflows

If you only need one Node.js version and want package-managed updates through apt upgrade, start with the Debian repository or NodeSource method. Pick NVM if your projects require different Node.js versions or if you need a newer Current line before extrepo data exposes it.

These instructions cover Debian 13 (Trixie), Debian 12 (Bookworm), and Debian 11 (Bullseye).

The NodeSource and NVM methods use the same commands across all supported releases. The Debian repository method uses the same install command, but the default Node.js version depends on your Debian release.

Before installing, refresh package metadata and install pending updates so dependency resolution stays clean:

sudo apt update && sudo apt upgrade

If your account is not configured for sudo yet, follow how to add a user to sudoers on Debian, then continue.

Install Node.js from Debian Repositories

Default Node.js Versions in Debian Repositories

Debian ReleaseDefault nodejsDefault npmUpstream Status
Debian 13 (Trixie)20.19.x9.2.xEOL upstream, Debian-maintained package
Debian 12 (Bookworm)18.20.x9.2.xEOL upstream, Debian-maintained package
Debian 11 (Bullseye)12.22.x7.5.xEOL upstream, Debian-maintained package

Check Available Node.js Versions on Debian

Check available candidates before installing:

apt-cache policy nodejs
apt-cache policy npm

Install Node.js and npm from Debian

Install nodejs and npm together since Debian ships them as separate packages:

sudo apt install nodejs npm

Verify the installed versions:

node --version
npm --version
# Debian 13 (Trixie)
v20.19.2
9.2.0

# Debian 12 (Bookworm)
v18.20.4
9.2.0

# Debian 11 (Bullseye)
v12.22.12
7.5.2

Debian appends the +dfsg suffix to some package versions to indicate Debian Free Software Guidelines repackaging; it does not mean this is a different Node.js upstream release.

Only the Debian repository method has release-specific version output. The NodeSource and NVM examples use the same commands on Debian 13, 12, and 11; their output changes when you choose a different Node.js stream or when upstream publishes a newer patch release.

Debian can continue maintaining its packaged Node.js branches through Debian updates, but these default major versions are upstream end-of-life. For current JavaScript projects, use NodeSource via extrepo or NVM so the runtime follows an upstream-supported Node.js line. See the official Node.js end-of-life schedule for details.

Install Node.js from NodeSource on Debian with extrepo

extrepo is Debian’s packaged tool for enabling third-party repositories from Debian-maintained metadata. It can enable the NodeSource APT source without a pipe-to-shell setup script, but its available streams follow the packaged extrepo-data entries rather than every stream NodeSource publishes directly.

Install extrepo and Discover NodeSource Entries

sudo apt install extrepo
extrepo search node

You should see entries such as node_24.x and node_22.x, plus any Current or older streams present in the packaged extrepo data. Prefer node_24.x for most new projects because it is the current Active LTS line.

Enable NodeSource Node.js Stream on Debian

Enable the stream you want. This example uses Node.js 24.x (Active LTS). If your project needs a different major line, enable only one NodeSource stream at a time:

sudo extrepo enable node_24.x

Common upstream-supported Node.js lines to look for in extrepo output include:

  • node_22.x: Maintenance LTS (Jod)
  • node_24.x: Active LTS (Krypton), recommended for most new projects
  • node_25.x: Current stream when your packaged extrepo data exposes it

Node.js 24 (Krypton) is the Active LTS line, Node.js 22 (Jod) is Maintenance LTS, and Node.js 20 (Iron) has reached upstream end-of-life. Current releases move faster than LTS releases and can appear in NodeSource before extrepo data exposes them. Confirm lifecycle windows at the Node.js release schedule.

Install Node.js from NodeSource

Update APT metadata to pick up the new repository:

sudo apt update

Confirm nodejs is being offered by NodeSource before installation:

apt-cache policy nodejs | sed -n '1,12p'
nodejs:
  Installed: (none)
  Candidate: 24.15.0-1nodesource1
  Version table:
    24.15.0-1nodesource1 500
      500 https://deb.nodesource.com/node_24.x nodistro/main amd64 Packages

Install Node.js. NodeSource bundles npm inside the nodejs package, so no separate npm package is required:

sudo apt install nodejs

Confirm the versions:

node --version
npm --version
v24.15.0
11.12.1

NodeSource packages update through regular apt upgrade cycles. To automate security patches, configure unattended upgrades on Debian.

Do not add a manual NodeSource .sources file while extrepo is active. Both files point to the same APT source with different Signed-By paths, and APT on Debian 13+ rejects duplicate sources outright. If you switch methods, fully remove the previous configuration first.

Install Node.js on Debian with NVM

NVM (Node Version Manager) lets you install and switch between Node.js majors from your home directory. It runs entirely in user space, so it can coexist with APT-installed Node.js; your active node command follows whichever path is first in your shell session.

Install NVM on Debian

The dynamic installer needs an HTTPS downloader. Minimal Debian installs (especially netinst images) often omit curl, so install it with certificate support first if needed:

sudo apt install curl ca-certificates

Resolve the latest NVM release tag from GitHub, then download and run the matching installer using curl:

latest_nvm="$(curl -fsSL https://api.github.com/repos/nvm-sh/nvm/releases/latest | sed -n 's/.*"tag_name": "\(v[^"]*\)".*/\1/p')"
if [ -z "$latest_nvm" ]; then
  echo "Could not resolve latest NVM release"
else
  curl -fsSL "https://raw.githubusercontent.com/nvm-sh/nvm/${latest_nvm}/install.sh" | bash
fi

For repeatable server builds, pin a tested NVM release tag instead of resolving the latest tag at install time.

Or install and use wget if you prefer it over curl:

sudo apt install wget ca-certificates
latest_nvm="$(wget -qO- https://api.github.com/repos/nvm-sh/nvm/releases/latest | sed -n 's/.*"tag_name": "\(v[^"]*\)".*/\1/p')"
if [ -z "$latest_nvm" ]; then
  echo "Could not resolve latest NVM release"
else
  wget -qO- "https://raw.githubusercontent.com/nvm-sh/nvm/${latest_nvm}/install.sh" | bash
fi

The script clones the NVM repository into ~/.nvm and appends initialization lines to your shell profile. Load NVM into the current shell without reloading your whole profile:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

Confirm NVM loaded correctly:

command -v nvm
nvm

NVM is a shell function, not a binary. which nvm always returns nothing, so use command -v nvm to verify it is available. See the which command guide for more on how shell lookups work.

List Available Node.js Versions with NVM

View all available Node.js versions:

nvm ls-remote

LTS releases are marked with their codenames (Iron, Jod, Krypton). To show only LTS versions:

nvm ls-remote --lts

Install a Node.js Version with NVM on Debian

Install the latest LTS version:

nvm install --lts

To install the latest Current release instead, use NVM’s node alias:

nvm install node

Alternatively, install a specific version by number:

nvm install 24
Downloading and installing node v24.15.0...
Downloading https://nodejs.org/dist/v24.15.0/node-v24.15.0-linux-x64.tar.xz...
######################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v24.15.0 (npm v11.12.1)
node --version
npm --version
v24.15.0
11.12.1

Switch Between Node.js Versions with NVM

Once you have multiple versions installed, switching is one command. First, add another version:

nvm install 22

Switch to a different installed version:

nvm use 22
Now using node v22.22.3 (npm v10.9.8)

To set a default version that persists across terminal sessions:

nvm alias default 24

View all installed versions and see which is currently active:

nvm ls
->      v22.22.3
        v24.15.0
default -> 24 (-> v24.15.0)
node -> stable (-> v24.15.0) (default)
stable -> 24.15 (-> v24.15.0) (default)
lts/* -> lts/krypton (-> v24.15.0)

To pin a Node.js version per project, create a .nvmrc file containing the major version number (for example, 24) in the project root. Running nvm use in that directory auto-switches to the pinned version. This pairs well with Yarn on Debian for package management and Git on Debian for version control.

Use Node.js and npm After Installation

After installation, basic Node.js usage is the same on Debian 13, 12, and 11. Check which commands are active in your current shell:

command -v node
command -v npm
command -v npx

NVM-managed commands usually resolve under your home directory, while Debian and NodeSource packages resolve under /usr/bin:

# NVM-managed shell
/home/username/.nvm/versions/node/v24.15.0/bin/node
/home/username/.nvm/versions/node/v24.15.0/bin/npm
/home/username/.nvm/versions/node/v24.15.0/bin/npx

# Debian or NodeSource package
/usr/bin/node
/usr/bin/npm
/usr/bin/npx

Run a quick Node.js command and check the npm and npx versions:

node -e "console.log('Node.js ' + process.version)"
npm --version
npx --version

With the NodeSource or NVM Node.js 24 examples, output should look similar to this:

Node.js v24.15.0
11.12.1
11.12.1

If you installed Node.js with NVM and the system still shows Debian or NodeSource paths, reload NVM or run nvm use 24 in that shell before starting your project.

Update Node.js on Debian

Use the update path that matches your installation method so you do not mix package sources.

Update Debian Repository Node.js Packages

If you installed Node.js from Debian repositories, upgrade nodejs and npm together:

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

Verify installed versions:

node --version
npm --version

The reported version depends on your Debian release. Refer to the default version table in the Debian repository method for the expected output on each release.

Update NodeSource Node.js Packages via extrepo

NodeSource minor and patch updates arrive through regular APT operations:

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

To switch to a different major line (for example, from 22.x to 24.x), disable the old stream and enable the new one:

sudo extrepo disable node_22.x
sudo extrepo enable node_24.x
sudo apt update
sudo apt install nodejs

Confirm APT is using the NodeSource candidate:

apt-cache policy nodejs | sed -n '1,8p'
nodejs:
  Installed: 24.15.0-1nodesource1
  Candidate: 24.15.0-1nodesource1
  Version table:
 *** 24.15.0-1nodesource1 500
       500 https://deb.nodesource.com/node_24.x nodistro/main amd64 Packages

Update Node.js with NVM on Debian

NVM upgrades by installing the target version and switching aliases:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install 24
nvm alias default 24
nvm use 24
Now using node v24.15.0 (npm v11.12.1)
default -> 24 (-> v24.15.0)

Troubleshoot Node.js on Debian

Most Node.js setup issues on Debian come from shell initialization, npm prefix permissions, or NodeSource key and source-definition conflicts.

Fix “Command Not Found” After NVM Installation on Debian

If you see this after running the installer:

bash: nvm: command not found

Your current shell has not loaded the NVM initialization lines yet. Reload the right shell profile:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

For Zsh users, source the Zsh configuration instead:

source ~/.zshrc

Verify that nvm is now available:

command -v nvm
nvm

Fix NodeSource Repository Signature or Source Conflicts on Debian

If apt update fails with key or source-definition conflicts after NodeSource changes, inspect every NodeSource source definition first:

grep -R "deb.nodesource.com" /etc/apt/sources.list /etc/apt/sources.list.d 2>/dev/null

Keep one source for the same NodeSource stream. If you are using extrepo, refresh the extrepo-managed source and key:

sudo extrepo disable node_24.x
sudo rm -f /etc/apt/sources.list.d/extrepo_node_24.x.sources
sudo rm -f /var/lib/extrepo/keys/node_24.x.asc
sudo extrepo enable node_24.x
sudo apt update

If the conflict came from an older NodeSource setup script or a manual NodeSource source file, remove those duplicate files only when you are switching to the extrepo method:

sudo rm -f /etc/apt/sources.list.d/nodesource.sources
sudo rm -f /etc/apt/sources.list.d/nodesource.list
sudo rm -f /usr/share/keyrings/nodesource.gpg
sudo apt update

Verify the repository is active:

apt-cache policy nodejs | grep deb.nodesource -m 1
500 https://deb.nodesource.com/node_24.x nodistro/main amd64 Packages

Fix Permission Denied During Global npm Install on Debian

If global npm installs fail with an error like this:

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/lib/node_modules

Check your current npm prefix:

npm config get prefix
/usr

If it points to a system directory and you are using the Debian or NodeSource package, set a user-writable prefix. Do not set a custom npm prefix while an NVM-managed Node.js version is active because it can break version switching.

mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
export PATH="$HOME/.npm-global/bin:$PATH"

Verify the updated prefix:

npm config get prefix
/home/username/.npm-global

NVM also avoids this issue because it installs packages into user-owned paths by default.

Remove Node.js from Debian

Use the removal steps that match your installation method so stale repositories and shell fragments do not linger.

Remove Node.js Installed from Debian Repositories

For the Debian repository, remove both packages since they are installed separately:

sudo apt remove --purge nodejs npm
sudo apt autoremove

Confirm Node.js is removed from the system:

apt-cache policy nodejs
node --version
nodejs:
  Installed: (none)
  Candidate: 20.19.2+dfsg-1+deb13u2
  Version table:
    20.19.2+dfsg-1+deb13u2 500
      500 http://deb.debian.org/debian trixie/main amd64 Packages
bash: node: command not found

Remove Node.js Installed from NodeSource with extrepo

For NodeSource, remove the nodejs package. The NodeSource package includes npm, so do not add Debian’s separate npm package to this command unless you installed it separately:

sudo apt remove --purge nodejs
sudo apt autoremove

Disable the extrepo source for the stream you used and remove its generated source and key files:

sudo extrepo disable node_24.x
sudo rm -f /etc/apt/sources.list.d/extrepo_node_24.x.sources
sudo rm -f /var/lib/extrepo/keys/node_24.x.asc
sudo apt update

Confirm NodeSource is no longer the candidate source:

apt-cache policy nodejs
node --version
nodejs:
  Installed: (none)
  Candidate: 20.19.2+dfsg-1+deb13u2
  Version table:
    20.19.2+dfsg-1+deb13u2 500
      500 http://deb.debian.org/debian trixie/main amd64 Packages
bash: node: command not found

Optionally remove the npm cache directory from your home folder if no other Node.js installation needs it:

rm -rf ~/.npm

Remove Node.js Installed via NVM

When using NVM, you can remove individual Node.js versions or uninstall NVM entirely.

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm current

Deactivate the current version before removing it:

nvm deactivate
nvm uninstall 24

To completely remove NVM and all installed Node.js versions, delete the NVM directory:

The next command permanently deletes NVM and every Node.js version installed through it, including globally installed npm packages under the NVM tree.

rm -rf ~/.nvm

Optionally remove the npm cache if you do not need cached packages for another Node.js installation:

rm -rf ~/.npm

Remove the NVM initialization block from ~/.bashrc (and ~/.zshrc if you use Zsh). Open the file and delete the three lines that begin with export NVM_DIR= and load nvm.sh:

nano ~/.bashrc

Find and delete the block that looks like this:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Save and close the file, then reload the shell configuration:

source ~/.bashrc

Confirm NVM and Node.js are no longer available:

command -v nvm
node --version
bash: node: command not found

Conclusion

Node.js is installed on Debian through the package source that matches your project: Debian’s repository for conservative system packages, NodeSource via extrepo for an APT-managed LTS stream, or NVM for per-project version switching. Next, set up Visual Studio Code on Debian for editing or add Docker on Debian when builds need containers.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: