{"id":165030,"date":"2026-03-29T12:13:24","date_gmt":"2026-03-29T09:13:24","guid":{"rendered":"https:\/\/computingforgeeks.com\/install-nodejs-void-linux\/"},"modified":"2026-03-29T21:17:32","modified_gmt":"2026-03-29T18:17:32","slug":"install-nodejs-void-linux","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/install-nodejs-void-linux\/","title":{"rendered":"Install Node.js and npm on Void Linux"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p><em>Last verified: <strong>March 2026<\/strong> | Void Linux (glibc), Node.js 24.13.0, npm 11.6.2<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Void Linux (glibc or musl, x86_64) with root or sudo access<\/li>\n<li>Updated system: <code>sudo xbps-install -Su<\/code><\/li>\n<li>Tested on: Void Linux glibc rolling (March 2026), kernel 6.12<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Install Node.js from Void Repos<\/h2>\n\n\n\n<p>The <code>nodejs<\/code> package in Void&#8217;s repos pulls in both the Node.js runtime and npm. One command does it all:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo xbps-install -y nodejs<\/code><\/pre>\n\n\n\n<p>Confirm the installed Node.js version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node --version<\/code><\/pre>\n\n\n\n<p>You should see:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>v24.13.0<\/code><\/pre>\n\n\n\n<p>Check npm as well:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm --version<\/code><\/pre>\n\n\n\n<p>The output confirms npm is ready:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>11.6.2<\/code><\/pre>\n\n\n\n<p>That&#8217;s the entire installation from Void&#8217;s repos. Both binaries land in <code>\/usr\/bin\/<\/code> and are immediately available system-wide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Node.js via NVM<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Grab the NVM installer from GitHub:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.40.1\/install.sh | bash<\/code><\/pre>\n\n\n\n<p>Reload your shell so the <code>nvm<\/code> command becomes available:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source ~\/.bashrc<\/code><\/pre>\n\n\n\n<p>Install the latest LTS release:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nvm install --lts<\/code><\/pre>\n\n\n\n<p>NVM downloads, compiles (if needed), and activates the LTS version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Installing latest LTS version.\nDownloading and installing node v22.15.0...\nDownloading https:\/\/nodejs.org\/dist\/v22.15.0\/node-v22.15.0-linux-x64.tar.xz...\nNow using node v22.15.0 (npm v10.9.2)<\/code><\/pre>\n\n\n\n<p>You can also install a specific major version. For example, Node.js 20:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nvm install 20<\/code><\/pre>\n\n\n\n<p>Switch between installed versions with <code>nvm use<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nvm use 22<\/code><\/pre>\n\n\n\n<p>List all versions NVM has installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nvm ls<\/code><\/pre>\n\n\n\n<p>The output shows installed versions with an arrow pointing to the active one:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>->     v22.15.0\n       v20.19.0\ndefault -> lts\/* (-> v22.15.0)\nlts\/* -> lts\/jod (-> v22.15.0)\nlts\/jod -> v22.15.0<\/code><\/pre>\n\n\n\n<p>Set a default version so every new shell session uses it automatically:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nvm alias default 22<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Test with a Simple HTTP Server<\/h2>\n\n\n\n<p>A quick sanity check to make sure Node.js actually works. Create a minimal HTTP server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat > \/tmp\/test.js << 'SCRIPT'\nconst http = require('http');\nconst server = http.createServer((req, res) => {\n  res.writeHead(200, { 'Content-Type': 'text\/plain' });\n  res.end('Node.js is working on Void Linux\\n');\n});\nserver.listen(3000, () => {\n  console.log('Server running at http:\/\/localhost:3000\/');\n});\nSCRIPT<\/code><\/pre>\n\n\n\n<p>Start the server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node \/tmp\/test.js &<\/code><\/pre>\n\n\n\n<p>Hit it with curl to verify the response:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl http:\/\/localhost:3000\/<\/code><\/pre>\n\n\n\n<p>You should get back:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Node.js is working on Void Linux<\/code><\/pre>\n\n\n\n<p>Kill the test server when you&#8217;re done:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kill %1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Install Yarn (Alternative Package Manager)<\/h2>\n\n\n\n<p>Some projects use Yarn instead of npm. Void carries it in the repos:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo xbps-install -y yarn<\/code><\/pre>\n\n\n\n<p>Verify the installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn --version<\/code><\/pre>\n\n\n\n<p>If you prefer installing Yarn through npm instead (useful when running Node.js via NVM):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install -g yarn<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Build a Quick Express.js App<\/h2>\n\n\n\n<p>Express is the most common Node.js web framework. Here&#8217;s a minimal setup to confirm everything works end to end.<\/p>\n\n\n\n<p>Create a project directory and initialize it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p ~\/myapp && cd ~\/myapp\nnpm init -y<\/code><\/pre>\n\n\n\n<p>Install Express:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install express<\/code><\/pre>\n\n\n\n<p>Create the application file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat > ~\/myapp\/index.js << 'SCRIPT'\nconst express = require('express');\nconst app = express();\nconst port = 3000;\n\napp.get('\/', (req, res) => {\n  res.send('Express.js running on Void Linux');\n});\n\napp.listen(port, () => {\n  console.log(`App listening on http:\/\/localhost:${port}`);\n});\nSCRIPT<\/code><\/pre>\n\n\n\n<p>Start the Express app:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node ~\/myapp\/index.js &<\/code><\/pre>\n\n\n\n<p>Test the endpoint:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl http:\/\/localhost:3000\/<\/code><\/pre>\n\n\n\n<p>The response confirms Express is serving requests:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Express.js running on Void Linux<\/code><\/pre>\n\n\n\n<p>Stop the background process once you&#8217;ve confirmed it works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kill %1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Run Node.js as a Runit Service<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Create the service directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/etc\/sv\/myapp<\/code><\/pre>\n\n\n\n<p>Create the run script. This is the equivalent of a systemd unit file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tee \/etc\/sv\/myapp\/run > \/dev\/null << 'SCRIPT'\n#!\/bin\/sh\nexec chpst -u nobody node \/home\/your-user\/myapp\/index.js 2>&1\nSCRIPT<\/code><\/pre>\n\n\n\n<p>Replace <code>\/home\/your-user\/myapp\/index.js<\/code> with the actual path to your application. Make the script executable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod +x \/etc\/sv\/myapp\/run<\/code><\/pre>\n\n\n\n<p>Enable the service by symlinking it into the active services directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ln -s \/etc\/sv\/myapp \/var\/service\/<\/code><\/pre>\n\n\n\n<p>Runit picks it up within a few seconds. Check the status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sv status myapp<\/code><\/pre>\n\n\n\n<p>A healthy service shows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>run: myapp: (pid 1234) 5s<\/code><\/pre>\n\n\n\n<p>Common runit commands for managing the service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sv restart myapp\nsudo sv stop myapp\nsudo sv start myapp<\/code><\/pre>\n\n\n\n<p>To add logging, create a log directory and script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/etc\/sv\/myapp\/log\nsudo tee \/etc\/sv\/myapp\/log\/run > \/dev\/null << 'SCRIPT'\n#!\/bin\/sh\nexec svlogd -tt \/var\/log\/myapp\nSCRIPT\nsudo chmod +x \/etc\/sv\/myapp\/log\/run\nsudo mkdir -p \/var\/log\/myapp<\/code><\/pre>\n\n\n\n<p>Application stdout and stderr will be captured in <code>\/var\/log\/myapp\/current<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Node.js Version Comparison<\/h2>\n\n\n\n<p>Depending on how you install Node.js, you get different versions. Here's what each method provides as of March 2026:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Method<\/th><th>Node.js Version<\/th><th>npm Version<\/th><th>Notes<\/th><\/tr><\/thead><tbody><tr><td>xbps (Void repos)<\/td><td>24.13.0<\/td><td>11.6.2<\/td><td>System-wide, tracks Void's rolling updates<\/td><\/tr><tr><td>NVM (LTS)<\/td><td>22.15.0<\/td><td>10.9.2<\/td><td>Per-user, ideal for production apps<\/td><\/tr><tr><td>NVM (Current)<\/td><td>24.13.0<\/td><td>11.6.2<\/td><td>Per-user, latest features<\/td><\/tr><tr><td>NVM (v20.x)<\/td><td>20.19.0<\/td><td>10.8.2<\/td><td>Per-user, previous LTS<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>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 <a href=\"https:\/\/computingforgeeks.com\/manage-nodejs-versions-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">managing multiple Node.js versions across projects<\/a>, NVM paired with <code>.nvmrc<\/code> files per repo keeps everything consistent. The <a href=\"https:\/\/nodejs.org\/en\/docs\" target=\"_blank\" rel=\"noreferrer noopener\">Node.js documentation<\/a> covers the full API reference for streams, workers, and the module system.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>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. This guide covers installation via both the native xbps package manager and NVM (for version flexibility), along with setting up Yarn, &#8230; <a title=\"Install Node.js and npm on Void Linux\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/install-nodejs-void-linux\/\" aria-label=\"Read more about Install Node.js and npm on Void Linux\">Read more<\/a><\/p>\n","protected":false},"author":32,"featured_media":165025,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[690,299,50],"tags":[],"class_list":["post-165030","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","category-how-to","category-linux-tutorials"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/165030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=165030"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/165030\/revisions"}],"predecessor-version":[{"id":165079,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/165030\/revisions\/165079"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/165025"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=165030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=165030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=165030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}