Node.js is a cross-platform JavaScript runtime built on Chrome’s V8 engine. It lets you run JavaScript outside the browser – making it the foundation for server-side applications, REST APIs, real-time services, and command-line tools. Node.js uses an event-driven, non-blocking I/O model that handles thousands of concurrent connections efficiently.
This guide covers multiple ways to install Node.js on Debian 13 (Trixie) and Debian 12 (Bookworm). We walk through the default Debian repository, the NodeSource repository for the latest LTS release, nvm for managing multiple versions, and Snap packages. The current Active LTS is Node.js 24 (codename Krypton), while Node.js 22 (Jod) is in Maintenance LTS.
Prerequisites
Before you begin, confirm you have:
- A server or desktop running Debian 13 (Trixie) or Debian 12 (Bookworm)
- Root or sudo access
- Working internet connection
- Basic familiarity with the Linux terminal
If you are still on Debian 12 and planning to move to Debian 13, check our guide on upgrading to Debian 13 from Debian 12.
Step 1: Install Node.js from Debian Repositories
The simplest method is installing Node.js directly from Debian’s default repositories. Debian 13 ships Node.js 20.x and Debian 12 ships Node.js 18.x. These are older LTS versions but are well-tested and receive security patches through the Debian security team.
Update the package index and install Node.js along with npm:
sudo apt update
sudo apt install -y nodejs npm
After installation, confirm the installed versions:
node --version
npm --version
On Debian 13, you should see Node.js v20.x. On Debian 12, the output shows v18.x:
v20.19.2
10.9.2
This method works well if you need a stable Node.js installation for basic tasks. For production applications that need the latest LTS features and performance improvements, use the NodeSource repository in Step 2 or nvm in Step 3.
Step 2: Install Node.js from NodeSource Repository (Latest LTS)
The NodeSource repository provides the latest Node.js LTS builds packaged for Debian. This is the recommended method for production servers since you get timely security updates through apt. Node.js 24 LTS (Krypton) is the current Active LTS release.
First, remove any existing Node.js installation from the default repositories to avoid conflicts:
sudo apt remove --purge -y nodejs npm
sudo apt autoremove -y
Install the required dependencies for adding the repository:
sudo apt update
sudo apt install -y ca-certificates curl gnupg
Download and run the NodeSource setup script for Node.js 24:
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
The script adds the NodeSource GPG key and repository to your system. Now install Node.js:
sudo apt install -y nodejs
Verify the installation shows the Node.js 24 LTS version:
node --version
npm --version
The output confirms Node.js 24 is installed with the bundled npm:
v24.14.0
10.9.2
The NodeSource package includes npm by default, so there is no need to install it separately. This package also handles updates through the standard apt upgrade workflow.
Step 3: Install Node.js with nvm (Version Manager)
nvm (Node Version Manager) lets you install and switch between multiple Node.js versions per user. This is the best option for developers working on projects that require different Node.js versions. Unlike the system-wide methods, nvm installs Node.js in your home directory – no sudo required.
Download and run the nvm install script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
Reload your shell configuration to make nvm available:
source ~/.bashrc
Confirm nvm is installed by checking its version:
nvm --version
You should see the version number confirming a successful installation:
0.40.4
Install the latest LTS version of Node.js:
nvm install --lts
nvm downloads, compiles (if needed), and activates the latest LTS release:
Installing latest LTS version.
Downloading and installing node v24.14.0...
Downloading https://nodejs.org/dist/v24.14.0/node-v24.14.0-linux-x64.tar.xz...
Now using node v24.14.0 (npm v10.9.2)
You can also install a specific version if your project requires it:
nvm install 22
Set the default Node.js version that loads in every new shell session:
nvm alias default 24
Step 4: Install Node.js with Snap
Snap packages provide another installation method with automatic updates. This works on any Linux distribution that supports snapd.
Install snapd if it is not already on your system:
sudo apt update
sudo apt install -y snapd
Install the Node.js LTS snap with classic confinement (required for Node.js to access the file system):
sudo snap install node --classic --channel=24
Verify the snap installation:
node --version
npm --version
The snap-installed Node.js updates automatically in the background, so you always have the latest patch release within the channel you selected.
Step 5: Verify Your Node.js Installation
Regardless of the installation method you chose, run these commands to confirm everything is working correctly.
Check the Node.js version:
node --version
Check the npm version:
npm --version
Verify the Node.js binary location:
which node
Depending on your installation method, the path will differ:
- Debian repo or NodeSource:
/usr/bin/node - nvm:
~/.nvm/versions/node/v24.14.0/bin/node - Snap:
/snap/bin/node
Run a quick JavaScript expression to confirm the runtime works:
node -e "console.log('Node.js ' + process.version + ' is running on ' + process.platform)"
You should see output confirming the version and platform:
Node.js v24.14.0 is running on linux
Step 6: Manage Multiple Node.js Versions with nvm
If you work on multiple projects that require different Node.js versions, nvm makes switching between them effortless. For a deeper dive into managing multiple versions, see our guide on running multiple versions of Node.js on Linux.
List all installed versions:
nvm ls
The output marks the currently active version with an arrow and shows aliases:
-> v24.14.0
v22.15.0
default -> 24 (-> v24.14.0)
node -> stable (-> v24.14.0)
lts/* -> lts/krypton (-> v24.14.0)
lts/jod -> v22.15.0
Switch to a different version for the current shell session:
nvm use 22
nvm confirms the switch immediately:
Now using node v22.15.0 (npm v10.9.2)
List all remote versions available for installation:
nvm ls-remote --lts
To uninstall a specific version you no longer need:
nvm uninstall 22
Step 7: Install Global Packages – Yarn and pnpm
npm comes bundled with Node.js, but you may want alternative package managers like Yarn or pnpm. These offer different performance characteristics and lock file formats.
Update npm itself to the latest version:
npm install -g npm@latest
Install Yarn globally:
npm install -g yarn
Install pnpm, which uses a content-addressable store to save disk space across projects:
npm install -g pnpm
Verify all package managers are available:
npm --version
yarn --version
pnpm --version
List all globally installed packages at any time:
npm list -g --depth=0
Other commonly installed global packages include nodemon for auto-restarting during development and pm2 for production process management. If you need a production process manager, check our guide on installing PM2 Node.js process manager.
Step 8: Create Your First Node.js Application
Test your setup by creating a simple HTTP server. This confirms Node.js, npm, and the runtime are all working together.
Create a project directory and initialize it:
mkdir ~/node-demo && cd ~/node-demo
npm init -y
Create a file called server.js with a basic HTTP server:
cat > server.js << 'ENDOFFILE'
const http = require('http');
const hostname = '0.0.0.0';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello from Node.js on Debian!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
ENDOFFILE
Start the server:
node server.js
You should see this output confirming the server is listening:
Server running at http://0.0.0.0:3000/
Open another terminal and test the server with curl:
curl http://localhost:3000
The server responds with our message:
Hello from Node.js on Debian!
Press Ctrl+C in the first terminal to stop the server. If you plan to expose this server on a network, open port 3000 in your firewall:
sudo ufw allow 3000/tcp
Conclusion
Node.js is now installed on your Debian system. You can use the Debian default packages for simplicity, the NodeSource repository for the latest LTS in production, nvm for per-user version management, or Snap for automatic updates. For production deployments, pair Node.js with a process manager like PM2 to handle restarts, logging, and clustering. For the full Node.js release schedule and version support dates, check the official Node.js releases page.