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 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. As of October 27, 2026, the patched Node.js 24 LTS release is:
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:
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.
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:
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 /tmp/nvm-install.sh
Load nvm into the current shell:
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:
nvm install 24 nvm alias default 24 nvm use 24
Verify:
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:
rm -rf ~/hello-node
To remove the NodeSource-installed Node.js package:
sudo apt remove -y nodejs
If you also want to remove the current NodeSource repository configuration, first inspect what exists:
ls -l /etc/apt/sources.list.d/nodesource* ls -l /usr/share/keyrings/nodesource.gpg
The current setup_24.x script uses these paths:
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:
nvm ls
Then uninstall only the version you no longer need:
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:
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:
cat /etc/apt/sources.list.d/nodesource.sources 2>/dev/null || true
Re-download and inspect the setup script if necessary:
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:
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:
gcc --version make --version python3 --version
Then install the base toolchain if needed:
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:
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.
