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.
Raff Technologies is used as the Ubuntu VM platform in the saved test workflow. As of September 7, 2026, the official Node.js download page lists Node.js 24.20.0 LTS and npm 11.19.0. Node.js 26 remains the Current release line. 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 Linux VM running Ubuntu 24.04
- 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 nodedepend 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:
sudo apt update sudo apt install -y ca-certificates curl gnupg
Confirm Ubuntu 24.04:
lsb_release -ds
Check whether Node.js or npm is already installed:
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:
curl -fsSL https://deb.nodesource.com/setup_24.x \ -o /tmp/nodesource_setup.sh
Inspect the script before running it:
sed -n '1,220p' /tmp/nodesource_setup.sh
Run the setup:
sudo -E bash /tmp/nodesource_setup.sh
Refresh APT metadata and inspect the repository configuration:
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:
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:
sudo apt install -y nodejs
Verify the runtime and package manager:
node --version npm --version command -v node command -v npm
The exact NodeSource package can advance after this tutorial is published. On September 7, 2026, the current official Node.js LTS release is:
v24.20.0
The official Node.js download page currently pairs that release with npm:
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:
sudo apt install -y build-essential python3
Verify the core tools:
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:
mkdir -p ~/hello-node cd ~/hello-node
Create server.js:
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:
node server.js
In a second SSH session, test it locally:
curl -i http://127.0.0.1:3000
Expected output includes:
HTTP/1.1 200 OK Hello from Node.js on Raff!
Confirm the listener is private:
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:
cd ~/hello-node npm init -y
Install Express locally:
npm install express
Check the dependency:
npm ls express
Create app.js:
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:
node app.js
From a second SSH session:
curl http://127.0.0.1:3000/ curl http://127.0.0.1:3000/health
Expected responses include:
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:
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.
