Dev

Install Node.js and npm on Void Linux

Void Linux ships Node.js 24.x directly in its official repositories, which means you can go from zero to a working Node.js environment in under a minute. No third-party repos, no Snap packages, no flatpaks.

Original content from computingforgeeks.com - post 165030

This guide covers installation via both the native xbps package manager and NVM (for version flexibility), along with setting up Yarn, building a quick Express.js app, and running Node.js as a runit service. If you need a specific Node.js version for a project, the NVM section has you covered.

Last verified: March 2026 | Void Linux (glibc), Node.js 24.13.0, npm 11.6.2

Prerequisites

  • Void Linux (glibc or musl, x86_64) with root or sudo access
  • Updated system: sudo xbps-install -Su
  • Tested on: Void Linux glibc rolling (March 2026), kernel 6.12

Install Node.js from Void Repos

The nodejs package in Void’s repos pulls in both the Node.js runtime and npm. One command does it all:

sudo xbps-install -y nodejs

Confirm the installed Node.js version:

node --version

You should see:

v24.13.0

Check npm as well:

npm --version

The output confirms npm is ready:

11.6.2

That’s the entire installation from Void’s repos. Both binaries land in /usr/bin/ and are immediately available system-wide.

Install Node.js via NVM

If your project requires a specific Node.js version (or you work across multiple projects pinned to different releases), NVM is the better approach. It installs Node.js versions per-user, independent of the system package.

Grab the NVM installer from GitHub:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

Reload your shell so the nvm command becomes available:

source ~/.bashrc

Install the latest LTS release:

nvm install --lts

NVM downloads, compiles (if needed), and activates the LTS version:

Installing latest LTS version.
Downloading and installing node v22.15.0...
Downloading https://nodejs.org/dist/v22.15.0/node-v22.15.0-linux-x64.tar.xz...
Now using node v22.15.0 (npm v10.9.2)

You can also install a specific major version. For example, Node.js 20:

nvm install 20

Switch between installed versions with nvm use:

nvm use 22

List all versions NVM has installed:

nvm ls

The output shows installed versions with an arrow pointing to the active one:

->     v22.15.0
       v20.19.0
default -> lts/* (-> v22.15.0)
lts/* -> lts/jod (-> v22.15.0)
lts/jod -> v22.15.0

Set a default version so every new shell session uses it automatically:

nvm alias default 22

Test with a Simple HTTP Server

A quick sanity check to make sure Node.js actually works. Create a minimal HTTP server:

cat > /tmp/test.js << 'SCRIPT'
const http = require('http');
const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Node.js is working on Void Linux\n');
});
server.listen(3000, () => {
  console.log('Server running at http://localhost:3000/');
});
SCRIPT

Start the server:

node /tmp/test.js &

Hit it with curl to verify the response:

curl http://localhost:3000/

You should get back:

Node.js is working on Void Linux

Kill the test server when you’re done:

kill %1

Install Yarn (Alternative Package Manager)

Some projects use Yarn instead of npm. Void carries it in the repos:

sudo xbps-install -y yarn

Verify the installation:

yarn --version

If you prefer installing Yarn through npm instead (useful when running Node.js via NVM):

npm install -g yarn

Build a Quick Express.js App

Express is the most common Node.js web framework. Here’s a minimal setup to confirm everything works end to end.

Create a project directory and initialize it:

mkdir -p ~/myapp && cd ~/myapp
npm init -y

Install Express:

npm install express

Create the application file:

cat > ~/myapp/index.js << 'SCRIPT'
const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.send('Express.js running on Void Linux');
});

app.listen(port, () => {
  console.log(`App listening on http://localhost:${port}`);
});
SCRIPT

Start the Express app:

node ~/myapp/index.js &

Test the endpoint:

curl http://localhost:3000/

The response confirms Express is serving requests:

Express.js running on Void Linux

Stop the background process once you’ve confirmed it works:

kill %1

Run Node.js as a Runit Service

Void Linux uses runit instead of systemd. To keep a Node.js app running persistently (and restart it on crash or reboot), create a runit service.

Create the service directory:

sudo mkdir -p /etc/sv/myapp

Create the run script. This is the equivalent of a systemd unit file:

sudo tee /etc/sv/myapp/run > /dev/null << 'SCRIPT'
#!/bin/sh
exec chpst -u nobody node /home/your-user/myapp/index.js 2>&1
SCRIPT

Replace /home/your-user/myapp/index.js with the actual path to your application. Make the script executable:

sudo chmod +x /etc/sv/myapp/run

Enable the service by symlinking it into the active services directory:

sudo ln -s /etc/sv/myapp /var/service/

Runit picks it up within a few seconds. Check the status:

sudo sv status myapp

A healthy service shows:

run: myapp: (pid 1234) 5s

Common runit commands for managing the service:

sudo sv restart myapp
sudo sv stop myapp
sudo sv start myapp

To add logging, create a log directory and script:

sudo mkdir -p /etc/sv/myapp/log
sudo tee /etc/sv/myapp/log/run > /dev/null << 'SCRIPT'
#!/bin/sh
exec svlogd -tt /var/log/myapp
SCRIPT
sudo chmod +x /etc/sv/myapp/log/run
sudo mkdir -p /var/log/myapp

Application stdout and stderr will be captured in /var/log/myapp/current.

Node.js Version Comparison

Depending on how you install Node.js, you get different versions. Here's what each method provides as of March 2026:

MethodNode.js Versionnpm VersionNotes
xbps (Void repos)24.13.011.6.2System-wide, tracks Void's rolling updates
NVM (LTS)22.15.010.9.2Per-user, ideal for production apps
NVM (Current)24.13.011.6.2Per-user, latest features
NVM (v20.x)20.19.010.8.2Per-user, previous LTS

Void's repos track the current release branch, so you get the newest Node.js without extra effort. If your application requires LTS stability, NVM is the way to go. For managing multiple Node.js versions across projects, NVM paired with .nvmrc files per repo keeps everything consistent. The Node.js documentation covers the full API reference for streams, workers, and the module system.

Related Articles

Windows Install Windows Admin Center on Windows Server 2025 Monitoring Web-Check: The Free Tool to Anylize Websites Books Best Google Cloud Certification Books for 2026 How To Top 10 Linux Tablets To Buy In 2025

Leave a Comment

Press ESC to close