How To Install Nodejs v18 on Ubuntu 22

I installed Ubuntu 22 on my new PC. When I installed nodejs, the default version installed was v12. So I want to upgrade it to version 18.

I tried few methods but only using nvm it was successful.

Different Methods To Install NodeJS on Ubuntu 22

  1. Installing Nodejs with APT from default repositories- fail
  2. Installing Nodejs with APT using a NodeSource PPA – fail
  3. Installing Nodejs using Node Version Manager – success

Refer this tutorial from DigitalOcean

My Steps Installing Nodejs using Node Version Manager (nvm)

1) Firstly list the node version you want to install

ubuntu 22 - choose node version
ubuntu 22 – choose node version

2) Secondly, choose the version you want to install. I chose LTS v18 @ lts/hydrogen

ubuntu 22 - install node v 18
ubuntu 22 – install node v 18

3) Check if you have installed the right version.

ubuntu 22 - successfully installed node v18
ubuntu 22 – successfully installed node v18

If You Got Checksum Error

At first, I had the checksum error, when I checked on the internet it was due to curl installed using SNAP (which I did). I have to re-install my curl using APT and remove the snap path from the path environment.

ubuntu 22 - install node v 18
ubuntu 22 – install node v 18

Curl still point to snap/bin.

ubuntu 22 - curl still point to snap
ubuntu 22 – curl still point to snap

ubuntu 22 - installing node problem due to curl installed by snap
ubuntu 22 – installing node problem due to curl installed by snap

Remove the snap/bin from the environment. Edit it using nano

ubuntu 22 - edit the path at environment
ubuntu 22 – edit the path at environment