If you’re ready to build server‑side apps or front‑end tooling using Node.js, you’ll want a solid setup. In this post, we’ll go through multiple ways to install Node.js on Ubuntu 24.04, and help you pick the method that best matches your needs.
Why Node.js + Ubuntu 24.04?
- Node.js lets you run JavaScript outside the browser — for servers, build tools, scripts, etc.
 - Ubuntu 24.04 is a recent LTS (Long Term Support) release, meaning stability, performance, and security.
 - Having flexible control over Node.js versions is useful: you may need the latest version, or a version compatible with certain projects, or multiple versions side‑by‑side.
 
Prerequisites
- A machine (or VM / server) running Ubuntu 24.04.
 - A user with root/sudo privileges.
 - Familiarity with the terminal / command line.
 
Methods to Install Node.js
We’ll cover three major methods. Each has pros & cons.
| Method | Pros | Cons | 
| Apt from Ubuntu’s default repos | Easiest, minimal setup | Version might be older or behind latest Node.js LTS / current release | 
| NodeSource PPA | Brings newer Node.js versions maintained by NodeSource; still pretty simple | Slightly more setup; using third‑party source | 
| NVM (Node Version Manager) | Can install multiple versions, switch between them; great for development | More steps; slight overhead; need to manage versions yourself | 
Step‑by‑Step Guide
Option 1: Install via Ubuntu’s Default APT Repos
Update the package index:
sudo apt update
Install nodejs:
sudo apt install nodejs
Install npm:
sudo apt install npm
Check that Node.js and npm are installed:
node --version
npm --version
This confirms they’re usable.
Option 2: Using NodeSource PPA (for newer versions)
If the Ubuntu default version is too old, the NodeSource PPA (personal package archive) lets you install more recent versions.
Download and run the NodeSource setup script. Replace 20.x with the version you want (e.g. 18.x, 20.x):
curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
You can review the contents of the file by:
nano nodesource_setup.sh
If you are satisfied that the script is safe to run, exit your editor, then run the script with:
sudo bash nodesource_setup.sh
Now install:
sudo apt update
sudo apt install -y nodejs
Verify:
node --version
Option 3: Using NVM (Node Version Manager)
If you ever need to switch Node.js versions often (e.g. different projects, testing), NVM is very useful.
Install NVM via its install script. (Always check the latest version on the official nvm GitHub page.)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.xx.x/install.sh | bash
(Replace v0.xx.x with the current release tag.)
Activate NVM in your current shell session:
source ~/.bashrc
List available Node versions:
nvm list‑remote
Install a version you want, for example latest LTS:
nvm install v23.10.0
You can see the different versions you installed by:
nvm list
Use a specific version (if multiple are installed):
nvm use <version>
The first line shows the currently active version (e.g., -> v23.10.0), followed by a list of named aliases and the versions they reference. You can also install a release using one of these aliases. For example, to install fermium, run the following command:
nvm install lts/fermium
To switch to another version, use:
nvm use <version no.>
Advanced / From‑Source (Optional)
If none of the above work (e.g. you need a very specific or patched version), you can compile from source. Steps generally include:
- Install build tools: build-essential, python3, make, etc.
 - Download the Node.js source tarball for your needed version.
 - Extract, configure, make, make install.
 - Adjust your PATH if installing to a non‑standard location.
 
This takes more time and effort, but gives full control.
Which Method Should You Use?
Here are some decision tips:
- Want minimal fuss → APT default
 - Need new Node version (but still stable) → NodeSource
 - Developer switching between projects with different Node versions → NVM
 
Want experimental/custom build → From‑source
Uninstall / Cleanup (if you need)
If you want to remove Node.js (and npm) fully:
Using apt:
sudo apt purge --auto-remove nodejs npm
Remove PPA if added (NodeSource):
# This depends on how it’s added; often by removing the nodesource list file
sudo rm /etc/apt/sources.list.d/nodesource*.list
# Also remove associated keyrings if needed
If using NVM, uninstall a specific version:
nvm uninstall <version>
If you are trying to uninstall active version, you first need to deactivate it and then uninstall:
nvm deactivate
Conclusion
Install Node.js on Ubuntu 24.04 is relatively straightforward, with multiple available paths depending on how you want to be or how much control you need. For most users, using the NodeSource PPA or NVM will give a good balance of stability and flexibility.
If you face any difficulties while trying to install Node.js on Ubuntu 24.04 or need expert assistance in configuring and maintaining your servers, our team at Skynats is here to help. With our professional Server Management services, we ensure your applications run smoothly, securely, and with optimized performance. Contact us today to get 24/7 support from our experienced engineers and let us handle the technical complexities for you.