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
- Installing Nodejs with APT from default repositories- fail
- Installing Nodejs with APT using a NodeSource PPA – fail
- 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
|
1 |
nvm ls-remote |

2) Secondly, choose the version you want to install. I chose LTS v18 @ lts/hydrogen
|
1 |
nvm install lts/hydrogen |
3) Check if you have installed the right version.
|
1 |
node -v |

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.

Curl still point to snap/bin.
|
1 |
curl |

|
1 |
echo $PATH |

Remove the snap/bin from the environment. Edit it using nano
|
1 |
sudo nano /etc/environment |
