How to Install Latest Node.js 20 on Ubuntu with PPA

Node.js is a platform built on Chrome’s JavaScript runtime to build fast and scalable network applications. The latest version of the Node.js PPA is maintained by its official website.

Add Nodesource PPA

Add the PPA to the Ubuntu system by running the following command.

apt-get install curl

curl -fsSL https://deb.nodesource.com/setup_20.x | bash -

Output:

root@vps:~# curl -fsSL https://deb.nodesource.com/setup_20.x | bash -

2024-02-12 14:27:55 - Installing pre-requisites
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [109 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1,371 kB]

Install Node.js

Installing the latest version of Node.js is now possible by running the following command,

apt-get install nodejs

Output:

root@vps:~# apt-get install nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
    nodejs
0 upgraded, 1 newly installed, 0 to remove and 64 not upgraded.
Need to get 26.1 MB of archives.
After this operation, 163 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_20.x nodistro/main amd64 nodejs amd64 20.11.0-1nodesource1 [26.1 MB]
Fetched 26.1 MB in 1s (49.6 MB/s)
Selecting previously unselected package nodejs.
(Reading database ... 72912 files and directories currently installed.)
Preparing to unpack .../nodejs_20.11.0-1nodesource1_amd64.deb ...
Unpacking nodejs (20.11.0-1nodesource1) ...
Setting up nodejs (20.11.0-1nodesource1) ...
Processing triggers for man-db (2.10.2-1) ...

now let's check the version of the Node.js installed,

  node -v

Output:

root@vps:~# node -v
v20.11.0

Done!