How to Install Latest Node.js on Ubuntu with PPA

Add Node.js PPA

Use Current Release: Node.js 13 is the current Node.js release available.

sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -

Output:

[email protected]:~# curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
## Installing the NodeSource Node.js 13.x repo...
## Populating apt-get cache...
+ apt-get update
Hit:1 http://de.archive.ubuntu.com/ubuntu eoan InRelease
Get:2 http://de.archive.ubuntu.com/ubuntu eoan-updates InRelease [97.5 kB]

Install Node.js on Ubuntu

Run the following command to install nodejs package

sudo apt-get install nodejs

output:

[email protected]:~# sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpython-stdlib libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib py

Check Node.js Version

Check the version Once the installation is complete

node -v

Output:

[email protected]:~# node -v
v13.0.

Uninstalling Node.js

If you wish to uninstall Nodejs and npm packages, you can run the command

sudo dpkg -r  nodejs

Output:

[email protected]:~# sudo dpkg -r  nodejs
(Reading database ... 111143 files and directories currently installed.)
Removing nodejs (13.0.1-1nodesource1) ...
Processing triggers for man-db (2.8.7-3) ...

To verify that nodejs is uninstalled you can run the following command

node -v

Output:

[email protected]:~# node -v
-bash: /usr/bin/node: No such file or directory