How to Install Node.js on Ubuntu 24.04

Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer
BeginnerUpdated Oct 27, 202614 min read~20 minutes total
Node.jsNode.js 24 LTSUbuntu 24.04npmNodeSourcenvmJavaScriptLinux
Last reviewed:
Tutorial
How to Install Node.js on Ubuntu 24.04
rafftechnologies.com/learn
On this page

Prerequisites

  • Ubuntu 24.04 Linux VM, SSH access with a non-root sudo user, outbound internet access for APT/npm, and no production dependency on an existing Node.js runtime you plan to replace.

Don’t have a server yet?

To install Node.js on Ubuntu 24.04, use a supported Node.js LTS release, verify which node binary your server is using, and keep installation testing local before exposing an application publicly. This tutorial installs Node.js 24 LTS and npm with NodeSource as the primary system-wide method, then shows nvm as a user-scoped alternative.

The saved test workflow used a Raff Linux VM. As of October 27, 2026, Node.js 24.22.1 LTS is the patched release that includes the October 21 security updates. Node.js 26 remains on the Current release line; use a supported LTS for production and confirm the installed npm version separately. The Node.js project recommends Active LTS or Maintenance LTS releases for production applications.

NodeSource currently supports Node.js 24 on Ubuntu 24.04 Noble. Its current setup_24.x script configures the node_24.x repository with the nodistro suite and supports amd64 and arm64. The alternative nvm workflow uses the current nvm 0.40.7 installer.

The original Node.js 24 workflow was tested on a Raff Ubuntu 24.04 VM with 1 vCPU and 2 GB RAM. Current Node.js, npm, NodeSource, and nvm guidance was documentation-reviewed for this refresh; no new full machine retest is claimed.

Prerequisites:

  • A Raff Ubuntu 24.04 Linux VM with SSH access
  • SSH access with a non-root user that has sudo privileges
  • Outbound internet access for APT and npm downloads
  • A review of any existing Node.js installation before replacing it

Choose one primary install method. Use NodeSource when you want a system-wide runtime managed through APT. Use nvm when one user needs multiple Node.js versions or a user-scoped development environment. Installing both can make command -v node depend on shell state and PATH ordering.

Step 1 — Prepare Ubuntu and check for an existing Node.js runtime

Update package metadata and install the tools needed for the NodeSource setup:

Bash
sudo apt update sudo apt install -y ca-certificates curl gnupg

Confirm Ubuntu 24.04:

Bash
lsb_release -ds

Check whether Node.js or npm is already installed:

Bash
node --version 2>/dev/null || echo "Node.js is not installed" npm --version 2>/dev/null || echo "npm is not installed" command -v node || true command -v npm || true

If an existing application depends on the installed runtime, stop here until you know how that application is started and how you will roll back.

Verify: Ubuntu should report 24.04 LTS, and you should know whether an existing Node.js installation or PATH override is present.

Step 2 — Add the NodeSource repository for Node.js 24

Download the NodeSource setup script to a file instead of piping it directly into a privileged shell:

Bash
curl -fsSL https://deb.nodesource.com/setup_24.x \ -o /tmp/nodesource_setup.sh

Inspect the script before running it:

Bash
sed -n '1,220p' /tmp/nodesource_setup.sh

Run the setup:

Bash
sudo -E bash /tmp/nodesource_setup.sh

Refresh APT metadata and inspect the repository configuration:

Bash
sudo apt update cat /etc/apt/sources.list.d/nodesource.sources apt-cache policy nodejs | sed -n '1,20p'

The current NodeSource script uses a source similar to:

Text
URIs: https://deb.nodesource.com/node_24.x Suites: nodistro

Do not replace nodistro with noble; the current NodeSource repository uses the nodistro suite for this installation path.

Verify: /etc/apt/sources.list.d/nodesource.sources should exist and apt-cache policy nodejs should show a NodeSource candidate for the Node.js 24 line.

Step 3 — Install Node.js 24 LTS and npm

Install the Node.js package:

Bash
sudo apt install -y nodejs

Verify the runtime and package manager:

Bash
node --version npm --version command -v node command -v npm

The exact NodeSource package can advance after this tutorial is published. As of October 27, 2026, the patched Node.js 24 LTS release is:

Text
v24.22.1

The earlier September download-page example used npm 11.19.0, but the bundled npm version can change independently; check the actual release with npm --version:

Text
11.19.0

A NodeSource system-wide installation should normally resolve node and npm under /usr/bin/.

Verify: node --version should report a supported v24 release, npm should run successfully, and the active binary paths should match the system-wide installation you intended.

Step 4 — Install build tools for native npm modules

Some npm dependencies contain native addons and may need a compiler toolchain when a compatible prebuilt binary is unavailable.

Install Ubuntu's standard build toolchain:

Bash
sudo apt install -y build-essential python3

Verify the core tools:

Bash
gcc --version | head -n 1 make --version | head -n 1 python3 --version

Not every Node.js project needs these tools, but having them available avoids a common failure mode when installing native npm dependencies.

Verify: GCC, Make, and Python should all be available.

Step 5 — Verify Node.js with a localhost-only HTTP server

Create a test project:

Bash
mkdir -p ~/hello-node cd ~/hello-node

Create server.js:

Bash
cat > server.js <<'EOF' const http = require('node:http'); const host = '127.0.0.1'; const port = 3000; const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' }); res.end('Hello from Node.js on Raff!\n'); }); server.listen(port, host, () => { console.log(`Server running at http://${host}:${port}/`); }); EOF

Start the server:

Bash
node server.js

In a second SSH session, test it locally:

Bash
curl -i http://127.0.0.1:3000

Expected output includes:

Text
HTTP/1.1 200 OK Hello from Node.js on Raff!

Confirm the listener is private:

Bash
ss -lntp | grep ':3000'

The listening address should be 127.0.0.1:3000, not 0.0.0.0:3000.

Stop the foreground process with Ctrl+C after testing. Do not create a public firewall rule for port 3000 just to make this installation test work.

Verify: the local request should return 200 OK and the Node.js process should listen only on loopback.

Step 6 — Initialize npm and test an Express dependency

Initialize the project:

Bash
cd ~/hello-node npm init -y

Install Express locally:

Bash
npm install express

Check the dependency:

Bash
npm ls express

Create app.js:

Bash
cat > app.js <<'EOF' const express = require('express'); const app = express(); const host = '127.0.0.1'; const port = 3000; app.get('/', (req, res) => { res.type('text/plain').send('Express is running on Node.js 24\n'); }); app.get('/health', (req, res) => { res.status(200).json({ status: 'ok' }); }); app.listen(port, host, () => { console.log(`Express listening on http://${host}:${port}`); }); EOF

Run the application:

Bash
node app.js

From a second SSH session:

Bash
curl http://127.0.0.1:3000/ curl http://127.0.0.1:3000/health

Expected responses include:

Text
Express is running on Node.js 24 {"status":"ok"}

Stop the foreground process with Ctrl+C.

Verify: npm ls express should succeed and both Express routes should return the expected response.

Step 7 — Verify the Node.js installation end to end

Run the final checks:

Bash
printf 'Node.js:\n' node --version printf '\nnpm:\n' npm --version printf '\nBinary paths:\n' command -v node command -v npm printf '\nAPT candidate:\n' apt-cache policy nodejs | sed -n '1,20p' printf '\nBuild tools:\n' gcc --version | head -n 1 make --version | head -n 1 python3 --version printf '\nProject dependency:\n' cd ~/hello-node npm ls express printf '\nRuntime platform:\n' node -e "console.log(process.version, process.platform, process.arch)"

The installation is complete when:

  • Node.js reports a supported v24 LTS release;
  • npm runs successfully;
  • the active binaries are the intended system-wide NodeSource installation;
  • APT sees the NodeSource Node.js 24 repository candidate;
  • GCC, Make, and Python are available for native addons;
  • Express is installed locally in the test project; and
  • the earlier localhost HTTP tests succeeded without exposing port 3000 publicly.

Alternative — Install Node.js 24 with nvm

Use nvm when a development user needs multiple Node.js versions or wants the runtime fully inside the user account. The official Node.js download page currently shows nvm 0.40.7 for Linux installation.

Download and inspect the installer:

Bash
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.7/install.sh \ -o /tmp/nvm-install.sh sed -n '1,200p' /tmp/nvm-install.sh

Run it as your normal user:

Bash
bash /tmp/nvm-install.sh

Load nvm into the current shell:

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

Install Node.js 24 and set it as the user's default:

Bash
nvm install 24 nvm alias default 24 nvm use 24

Verify:

Bash
nvm --version node --version npm --version command -v node

With nvm, command -v node should resolve inside ~/.nvm/ rather than /usr/bin/node.

For systemd services, do not assume an nvm-generated Node.js binary path remains stable after changing versions. Use a deliberately managed runtime path or update the service configuration as part of the runtime upgrade.

Why Ubuntu 24.04's default Node.js package is not the primary method

Ubuntu 24.04 Noble's base nodejs source package is from the Node.js 18.19.1 generation. Node.js 18 reached end of life on March 27, 2025.

A fresh production deployment should therefore use a currently supported Active LTS or Maintenance LTS release instead of choosing Node.js 18 only because it is available in the base Ubuntu repository.

Cleanup

Remove only the tutorial project:

Bash
rm -rf ~/hello-node

To remove the NodeSource-installed Node.js package:

Bash
sudo apt remove -y nodejs

If you also want to remove the current NodeSource repository configuration, first inspect what exists:

Bash
ls -l /etc/apt/sources.list.d/nodesource* ls -l /usr/share/keyrings/nodesource.gpg

The current setup_24.x script uses these paths:

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

Remove only files that belong to NodeSource on your server.

If you used nvm, list installed versions first:

Bash
nvm ls

Then uninstall only the version you no longer need:

Bash
nvm uninstall 24

Do not remove a runtime that an existing application or systemd service still depends on.

Troubleshooting

node --version does not report v24

Check the active binary and APT candidate:

Bash
command -v node node --version apt-cache policy nodejs | sed -n '1,20p'

If the shell resolves a binary inside ~/.nvm/, nvm may be overriding the system-wide NodeSource installation.

The NodeSource repository is missing

Check the current source file:

Bash
cat /etc/apt/sources.list.d/nodesource.sources 2>/dev/null || true

Re-download and inspect the setup script if necessary:

Bash
curl -fsSL https://deb.nodesource.com/setup_24.x \ -o /tmp/nodesource_setup.sh sed -n '1,220p' /tmp/nodesource_setup.sh

The current repository should use node_24.x with the nodistro suite.

nvm: command not found

Load nvm directly:

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

If that works, open a new login shell and confirm your shell profile contains the nvm initialization lines.

An npm package fails while compiling a native addon

Check the build prerequisites:

Bash
gcc --version make --version python3 --version

Then install the base toolchain if needed:

Bash
sudo apt install -y build-essential python3

Some packages also require their own development libraries; use the dependency's build documentation rather than weakening system permissions.

npm reports permission errors for global packages

Do not use broad fixes such as chmod 777. Prefer project-local dependencies, nvm for user-scoped global tools, or the installation method recommended by the CLI you are installing.

The local HTTP test does not respond

Check whether another process owns port 3000:

Bash
ss -lntp | grep ':3000'

Inspect the Node.js process output and use another loopback port if needed. Do not expose a troubleshooting port publicly just to make the local check pass.

Conclusion

You installed Node.js 24 LTS and npm on Ubuntu 24.04 using a system-wide NodeSource repository, verified the active runtime and APT source, installed native-module build tools, and tested Node.js and Express on loopback only.

Installing Node.js alone does not deploy an application as a managed service or put HTTPS in front of it. The next step is to run the application under a process manager and configure a reverse proxy.

For production application deployment, continue with Deploy Node.js with PM2 on Ubuntu 24.04, Install Nginx on Ubuntu 24.04, or Deploy Next.js with PM2 and Nginx.

Deploy a Raff Ubuntu VM for your Node.js application, then follow the PM2 and Nginx deployment tutorials before accepting public traffic.

Sources

  • Node.js — Downloads and release schedule
  • NodeSource distributions — Ubuntu 24.04 / Node.js 24 support and current setup script
  • nvm — v0.40.7 release and installer
  • Ubuntu Packages — Node.js source package for Noble
  • Guidance re-verified: 2026-09-07
Was this article helpful?
Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer

Aybars is a Platform Engineer & Technical Writer at Raff Technologies. He works on Linux VM templates, self-hosted application workflows, and security-focused deployment validation, turning tested infrastructure procedures into clear, practical tutorials for developers and teams.

Put it into practice

Spin up a Raff server, follow the steps above on real infrastructure, and you are live. Linux or Windows, backed by a 14-day money-back guarantee.

Frequently asked questions

How do I install Node.js on Ubuntu 24.04?
For a system-wide server runtime, add the NodeSource Node.js 24 repository, install the `nodejs` package with APT, then verify `node --version` and `npm --version`. Use nvm instead when one user needs to switch between multiple Node.js versions.
Which Node.js version should I use on Ubuntu 24.04 in 2026?
For production, use an actively supported Node.js LTS release. As of October 27, 2026, Node.js 24.22.1 LTS includes the October 21 security fixes; avoid older unpatched v24 builds. Check the runtime actually installed on your VM.
What npm version ships with the current Node.js 24 LTS download?
The bundled npm version can change between Node.js 24 patches. Use a current patched Node.js 24 LTS build (24.22.1 or later as of October 27, 2026) and check `npm --version` on the server rather than relying on a stale fixed npm number.
Should I use NodeSource or nvm on Ubuntu?
Use NodeSource when you want a system-wide Node.js runtime managed through APT. Use nvm for a user-scoped development environment or when one user needs to switch between multiple Node.js versions.
Does NodeSource support Node.js 24 on Ubuntu 24.04?
Yes. NodeSource currently lists Ubuntu Noble 24.04 as supported for Node.js 24 and its installation tests include Node.js 24 on Ubuntu 24.04.
Why not use Ubuntu 24.04's default Node.js package for a new production app?
Ubuntu 24.04's base repository is from the Node.js 18 generation, while Node.js 18 reached end of life on March 27, 2025. New production deployments should use a currently supported LTS line.
Should I open port 3000 after installing Node.js?
No for the installation test. Bind the test server to `127.0.0.1`; production Node.js applications should normally stay behind Nginx, another reverse proxy, a load balancer, or another controlled ingress layer.
Do I need build-essential for Node.js?
Not for Node.js itself, but some npm packages include native addons and may require GCC, Make, Python, or other development libraries when a compatible prebuilt binary is unavailable.