Debian ships a stable but older Node.js in its default repositories, which works for basic server tasks but falls behind what most JavaScript projects expect. Whether you need the Active LTS line (currently 24.x), the short-term Current release (25.x), or an older supported major, several methods let you install Node.js on Debian at the version your project actually requires.
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 bumps that to 25.x, 24.x, or 22.x with APT-managed updates, while NVM handles per-project version switching entirely from your home directory.
Compare the three methods before choosing one:
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| Debian Repositories | Debian Packages | Debian 13: 20.19.x, Debian 12: 18.20.x, Debian 11: 12.22.x | Automatic via apt upgrade | Stable server and workstation installs |
| NodeSource via extrepo | NodeSource | 25.x (Current), 24.x, 22.x, 20.x streams | Automatic via apt upgrade | Developers who need newer Node.js than Debian defaults |
| Node Version Manager (NVM) | NVM | Any supported Node.js version | Manual via nvm install | Per-project version switching and local dev workflows |
If you only need one Node.js version and want automatic security updates through apt upgrade, start with Method 1 or Method 2. Pick NVM if your projects require different Node.js versions.
These instructions cover Debian 13 (Trixie), Debian 12 (Bookworm), and Debian 11 (Bullseye).
Methods 2 and 3 use the same commands across all supported releases. Method 1 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
sudoyet, follow how to add a user to sudoers on Debian, then continue.
Method 1: Install Node.js from Debian Repositories
The Debian repository gives you a Node.js version tied to your Debian release with no extra repository setup or GPG key management.
Default Node.js Versions in Debian Repositories
| Debian Release | Default nodejs | Default npm | Upstream Status |
|---|---|---|---|
| Debian 13 (Trixie) | 20.19.x | 9.2.x | Maintenance LTS |
| Debian 12 (Bookworm) | 18.20.x | 9.2.x | End-of-life |
| Debian 11 (Bullseye) | 12.22.x | 7.5.x | End-of-life |
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.19.0 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.
Debian 12 ships Node.js 18, which reached end-of-life in April 2025. Debian 11 ships Node.js 12, which reached end-of-life in April 2022. For current projects on either release, use Method 2 (NodeSource via extrepo) or Method 3 (NVM). See the official Node.js end-of-life schedule for details.
Method 2: Install Node.js from NodeSource on Debian with extrepo
extrepo is Debian’s built-in tool for managing vetted third-party repositories. It enables the NodeSource APT source in one command, handles GPG keys automatically, and keeps your system policy-compliant. This is the recommended approach for Debian because it avoids manual key imports and repository file creation.
Install extrepo and Discover NodeSource Entries
sudo apt install extrepo
extrepo search node
You should see entries such as node_25.x, node_24.x, node_22.x, and node_20.x.
Enable NodeSource Node.js Stream on Debian
Enable the stream you want. This example uses Node.js 24.x (Active LTS). Substitute node_25.x if you need the latest Current release instead:
sudo extrepo enable node_24.x
Choose from the currently supported Node.js versions:
node_20.x: Maintenance LTS (Iron), nearing end-of-life and best avoided for new projectsnode_22.x: Maintenance LTS (Jod)node_24.x: Active LTS (Krypton), recommended for most new projectsnode_25.x: Current release with latest features and a shorter support window
Node.js 25 is the current short-term (Current) release, Node.js 24 (Krypton) is Active LTS, Node.js 22 (Jod) is Maintenance LTS, and Node.js 20 (Iron) is Maintenance LTS until April 2026. Node.js 18 and earlier have reached end-of-life and no longer receive security patches. Current releases include the newest features but only receive active support for six months. 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.14.0-1nodesource1
Version table:
24.14.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.14.0 11.9.0
NodeSource packages update through regular apt upgrade cycles. To automate security patches, configure unattended upgrades on Debian.
Do not add a manual NodeSource
.sourcesfile whileextrepois active. Both files point to the same APT source with differentSigned-Bypaths, and APT on Debian 13+ rejects duplicate sources outright. If you switch methods, fully remove the previous configuration first.
Method 3: Install Node.js on Debian with NVM
NVM (Node Version Manager) lets you install and switch between any Node.js major from your home directory. It runs entirely in user space, so it does not touch system packages or require sudo.
Install NVM on Debian
The install script needs curl. Minimal Debian installs (especially netinst images) often omit it, so install it first if needed:
sudo apt install curl
Download and run the NVM install script using curl:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
Or use wget if curl is not installed:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
The script clones the NVM repository into ~/.nvm and appends initialization lines to your shell profile. Load them into your current session without restarting the terminal. Zsh users should replace ~/.bashrc with ~/.zshrc.
source ~/.bashrc
Confirm NVM loaded correctly:
command -v nvm
nvm
NVM is a shell function, not a binary.
which nvmalways returns nothing, so usecommand -v nvmto 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
Alternatively, install a specific version by number:
nvm install 24
Downloading and installing node v24.14.0... Downloading https://nodejs.org/dist/v24.14.0/node-v24.14.0-linux-x64.tar.xz... ######################################################### 100.0% Computing checksum with sha256sum Checksums matched! Now using node v24.14.0 (npm v11.9.0)
node --version
npm --version
v24.14.0 11.9.0
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.0 (npm v10.9.4)
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.0
v24.14.0
default -> 24 (-> v24.14.0)
node -> stable (-> v24.14.0) (default)
stable -> 24.14 (-> v24.14.0) (default)
lts/* -> lts/krypton (-> v24.14.0)
To pin a Node.js version per project, create a
.nvmrcfile containing the major version number (for example,24) in the project root. Runningnvm usein 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.
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 Method 1 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.14.0-1nodesource1
Candidate: 24.14.0-1nodesource1
Version table:
*** 24.14.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:
source ~/.nvm/nvm.sh
nvm install 24
nvm alias default 24
nvm use 24
Now using node v24.14.0 (npm v11.9.0) default -> 24 (-> v24.14.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:
source ~/.bashrc
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:
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
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, set a user-writable prefix:
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
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 via APT
For the Debian repository, remove both packages since they are installed separately:
sudo apt remove --purge nodejs npm
sudo apt autoremove
Optionally remove the npm cache directory from your home folder:
rm -rf ~/.npm
If you used extrepo for NodeSource, also disable and clean its artifacts:
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 Node.js is removed from the system:
apt-cache policy nodejs
node --version
nodejs:
Installed: (none)
Candidate: 20.19.2~dfsg-1
Version table:
20.19.2~dfsg-1 500
500 http://deb.debian.org/debian trixie/main amd64 Packages
bash: node: command not found
Remove Node.js Installed via NVM
When using NVM, you can remove individual Node.js versions or uninstall NVM entirely.
source ~/.nvm/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
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
FAQ on Installing Node.js on Debian
Debian repositories are best when you want fully distro-managed packages and conservative updates. NodeSource through extrepo is usually better for active JavaScript development, especially on Debian 11 and 12, because it provides current LTS streams like 24.x. NVM is best when you need to run multiple Node.js versions side by side per project.
Yes. The NodeSource nodejs package includes npm, so you typically install only nodejs for that method. Debian repository installs usually use separate nodejs and npm packages.
Yes. NVM installs to your home directory and manages PATH in your shell session, while APT-installed Node.js remains in system paths. They can coexist, and you can switch to system binaries with nvm use system when needed.
LTS (Long Term Support) releases receive security patches and bug fixes for 30 months and are recommended for production servers. Current releases include the latest features but only receive active support for six months. On Debian, NodeSource offers both LTS and Current streams, while Debian’s own repositories track older stable versions that align closely with LTS timelines.
Debian 13 (Trixie) includes Node.js 20.x, Debian 12 (Bookworm) includes Node.js 18.x, and Debian 11 (Bullseye) includes Node.js 12.x. Node.js 18 and 12 are both upstream end-of-life, so use NodeSource via extrepo or NVM on Debian 11 and 12 when you need a supported runtime.
extrepo is Debian’s built-in tool for managing vetted third-party repositories. It handles GPG key imports and source file creation in a single command while following Debian’s packaging policy. Manual NodeSource setup works but requires managing keys and source files yourself, and mixing both methods causes APT source conflicts.
For Debian repository installs, run sudo apt update and sudo apt install --only-upgrade nodejs npm. For NodeSource via extrepo, run sudo apt update and sudo apt install --only-upgrade nodejs. To switch major lines, disable the old stream with sudo extrepo disable node_22.x and enable the new one with sudo extrepo enable node_24.x. For NVM, run nvm install 24, nvm alias default 24, and nvm use 24.
Disable the current stream with sudo extrepo disable node_22.x, then enable the new stream with sudo extrepo enable node_24.x, run sudo apt update, and install with sudo apt install nodejs. Only one NodeSource stream should be active at a time.
Conclusion
Node.js is running on Debian at the version your stack needs, whether that is distro-default packages, an LTS or Current stream from NodeSource via extrepo, or multiple majors managed through NVM. From here, install Yarn on Debian as an npm alternative, install Git on Debian for version control, set up Visual Studio Code on Debian for a full editing environment, and add Docker on Debian when you need containerized builds.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>