How to Install Node.js on Ubuntu 24.04: A Step‑by‑Step Guide
Node.js has revolutionized the way developers build server‑side applications and real‑time services using JavaScript. Ubuntu 24.04 “Noble Numbat,” with its Long‑Term Support status, provides a rock‑solid platform for running modern development stacks. In this post, we’ll demonstrate how to install Node.js on Ubuntu 24.04 using two proven approaches: the default Ubuntu repository and the NodeSource binary distributions. For more detailed instructions and troubleshooting tips, refer to the official Vultr documentation
Why Choose Node.js on Ubuntu 24.04?
Ubuntu 24.04 LTS delivers five years of security updates, performance enhancements, and compatibility improvements—all critical for production environments. Node.js, powered by Google’s V8 engine, excels at handling asynchronous I/O, making it ideal for:
Real‑time web applications (chats, games, collaboration tools)
RESTful APIs and microservices
Command‑line utilities and automation scripts
Server‑side rendering for modern web frameworks
Combining the stability of Ubuntu 24.04 with the scalability of Node.js lets you develop, test, and deploy applications with confidence.
Prerequisites
Before proceeding, ensure you have:
Ubuntu 24.04 installed (Desktop or Server edition)
Sudo privileges on your user account
Terminal or SSH access to your machine
An active internet connection
Method 1: Installing from Ubuntu’s Official Repository
Ubuntu’s built-in repositories include a version of Node.js, though it may not always match the latest LTS release. This approach is straightforward and sufficient for many projects.
Update package lists sudo apt update
Install Node.js sudo apt install -y nodejs
Install NPM sudo apt install -y npm
Verify installations node -v
npm -v
You should see version numbers for both Node.js and NPM. If these meet your project requirements, you’re all set!
Method 2: Using NodeSource to Get the Latest LTS Release
To ensure access to the most current LTS (Long‑Term Support) version of Node.js, you can add the NodeSource repository.
Fetch and run the NodeSource setup script curl -fsSL
This script automatically configures the NodeSource APT repository on your system.
Install Node.js (includes NPM) sudo apt install -y nodejs
Confirm installation node -v
npm -v
You’ll now have the latest LTS version of Node.js installed, complete with NPM.
Optional: Install Build Tools for Native Add‑ons
Some NPM packages include native components that require compilation. Install the necessary build tools:
sudo apt install -y build-essential
This ensures you can install and use packages like node-gyp, bcrypt, and more without errors.
Troubleshooting Common Issues
Permission errors when installing global packages: avoid using sudo npm install -g; instead, configure a per‑user NPM directory in your home folder or use a version manager like nvm.
Command not found for node: ensure /usr/bin is in your PATH, or verify that the binary is located there.
Firewall blocks: if running a server on a custom port (e.g., 3000), allow traffic through UFW: sudo ufw allow 3000
Conflicting versions: remove previous Node.js installations before adding NodeSource: sudo apt remove --purge nodejs npm
sudo apt autoremove
Uninstalling Node.js and NPM
If you need to remove Node.js and NPM entirely:
sudo apt remove --purge -y nodejs npm
sudo apt autoremove -y
This cleans out all related packages and dependencies.
Conclusion
Mastering how to install Node.js on Ubuntu 24.04 sets the foundation for building high‑performance, event‑driven JavaScript applications. Whether you opt for the simplicity of Ubuntu’s default repositories or the up‑to‑date NodeSource method, you’ll benefit from Ubuntu 24.04’s LTS stability and Node.js’s robust ecosystem. For a complete walkthrough, advanced options, and troubleshooting, visit the Vultr guide at Happy coding!

