Node.js is a fast, open-source JavaScript runtime that lets you build scalable server-side and network applications.
It is known for its non-blocking, event-driven architecture, making it ideal for building scalable network applications like APIs, chat apps, and real-time services.
Ubuntu 24.04 offers several ways to install Node.js
depending on your needs, whether you prefer stability or the latest features.
This blog post will guide you through three reliable methods to install Node.js on Ubuntu 24.04.
Method 1: Installing Node.js Using apt (Default Repository)
Ubuntu provides Node.js in its default repositories, but it may not be the latest version.
First, update the package list to ensure you have the latest repositories:
# apt update && sudo apt upgrade -y
Run the following command to install Node.js
and npm:
# apt install nodejs npm -y
Verify the installed version of Node.js
running the following command:
# node --version
You should see the following output:
v18.19.1
Verify the NPM version with the following command:
# npm --version
You should get the following output:
9.2.0
Method 2: Install Latest Node.js Using NodeSource
This method gives you access to the most recent versions of Node.js.
First, add the Node.js
repository running the following command:
# curl -sL https://deb.nodesource.com/setup_22.x | bash -
Once added, install the Node.js
with the following command:
# apt-get install nodejs
Verify the installed version of Node.js
running the following command:
# node --version
You should see the following output:
v22.14.0
Verify the NPM version with the following command:
# npm --version
You should get the following output:
10.9.2
Method 3: Install Node.js Using NVM (Node Version Manager)
Use this method if you want to install and manage multiple Node.js
versions easily.
# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# source ~/.bashrc
To install the latest LTS version:
# nvm install --lts
To install a specific version you can use the following command:
# nvm install 20
Replace “20″ with the version number of Node.js you want to install.
Comments and Conclusion
Installing Node.js
on Ubuntu 24.04 is straightforward with multiple flexible options:
- Use apt for a quick setup
- Use NodeSource for the latest stable versions
- Use NVM for full control over
Node.js
versions
Now that Node.js
is installed, you’re ready to start building apps and tools in JavaScript.
For additional help or useful information, we recommend you to checkĀ the official Node.js documentation.
If you have any questions please leave a comment below.