How to Install Latest Node.js 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 Node.js ppa

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

apt-get install curl

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

Output:

root@vps:~# curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

## Installing the NodeSource Node.js 12.x repo...

## Populating apt-get cache...

+ apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done

## Confirming "jammy" is supported...

Install Node.js

installing Node.js 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 additional packages will be installed:
  javascript-common libc-ares2 libjs-highlight.js libnode72 nodejs-doc
Suggested packages:
  apache2 | lighttpd | httpd npm
The following NEW packages will be installed:
  javascript-common libc-ares2 libjs-highlight.js libnode72 nodejs nodejs-doc

And check the version of the nodejs once the installation is done.

  node -v

Output:

root@vps:~# node -v
v12.22.9

Done!