Install Nodejs on Ubuntu 24.04

install nodejs

In this tutorial, you will learn how to install Nodejs on Ubuntu 24.04. Nodejs is a JavaScript runtime built on Chrome’s V8 JavaScript engine for easily building fast, scalable network applications. It uses an
event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is also bundled with several useful libraries to handle server tasks: System, Events, Standard I/O, Modules, Timers, Child Processes, POS

Installing Nodejs on Ubuntu 24.04

Nodejs is available on the default Ubuntu 24.04 main repos. However, the available versions may not be up-to-date.

For example, in the command output below, you can see that Nodejs 18.x is available on the default Ubuntu 24.04 repositories.

sudo apt update
apt-cache policy nodejs
  Installed: (none)
  Candidate: 18.19.1+dfsg-6ubuntu5
  Version table:
     18.19.1+dfsg-6ubuntu5 500
        500 noble/universe amd64 Packages

Install Nodejs APT Repository

Therefore, to install the latest, which is Nodejs 22.x, which is the current stable release as per the Nodejs releases page, you need to install Nodejs APT repository by executing the command below;

curl -sL | sudo -E bash -

Sample installation command output;

2024-05-11 08:58:52 - Installing pre-requisites
Hit:1 noble InRelease
Hit:2 noble-updates InRelease          
Hit:3 noble-backports InRelease        
Hit:4 noble-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20240203).
ca-certificates set to manually installed.
curl is already the newest version (8.5.0-2ubuntu10.1).
curl set to manually installed.
gnupg is already the newest version (2.4.4-2ubuntu17).
gnupg set to manually installed.
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 3,974 B of archives.
After this operation, 35.8 kB of additional disk space will be used.
Get:1 noble/universe amd64 apt-transport-https all 2.7.14build2 [3,974 B]
Fetched 3,974 B in 0s (13.5 kB/s)               
Selecting previously unselected package apt-transport-https.
(Reading database ... 85165 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.7.14build2_all.deb ...
Unpacking apt-transport-https (2.7.14build2) ...
Setting up apt-transport-https (2.7.14build2) ...
Scanning processes...                                                                                                                                                
Scanning candidates...                                                                                                                                               
Scanning linux images...                                                                                                                                             

Running kernel seems to be up-to-date.

Restarting services...

Service restarts being deferred:
 systemctl restart unattended-upgrades.service

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
Hit:1 noble-security InRelease
Hit:2 noble InRelease
Hit:3 noble-updates InRelease
Hit:4 noble-backports InRelease
Get:5 nodistro InRelease [12.1 kB]
Get:6 nodistro/main amd64 Packages [1,278 B]
Fetched 13.4 kB in 0s (27.0 kB/s)     
Reading package lists... Done
2024-05-11 08:58:56 - Repository configured successfully. To install Node.js, run: apt-get install nodejs -y

Install Nodejs

Once the repos are installed, you can now install Nodejs.

sudo apt install nodejs

Get the information about installed version of Nodejs on Ubuntu 24.04;

dpkg -l nodejs

Sample output;

| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version             Architecture Description
ii  nodejs         22.1.0-1nodesource1 amd64        Node.js event-based server-side javascript engine

You can also check installed version of Nodejs on Ubuntu 24.04;

node -v

Note that the command above also installs NPM along with Nodejs. You can verify by checking the version of installed NPM on Ubuntu 24.04.

npm -v

Install Nodejs Development Tools to Build Native Addons

If you need to build native Nodejs addons, you need to install some development tools by running the command below;

sudo apt install gcc g++ make

Install Yarn on Ubuntu 24.04

You may also want to install Yarn on Ubuntu 24.04. To do so, run the command below:

curl -sL | sudo gpg --dearmor -o  /etc/apt/trusted.gpg.d/yarnkey.gpg
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn

You can now proceed to build your web applications using Nodejs.

Getting Started with Nodejs

Read more on Nodejs getting started guide.


We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
Linux Certified Engineer, with a passion for open-source technology and a strong understanding of Linux systems. With experience in system administration, troubleshooting, and automation, I am skilled in maintaining and optimizing Linux infrastructure.

Leave a Comment