Update Node.js with NVM (Node Version Manager)
There are many ways that can be used to update the node version on a linux system. Bu the best and the recomended would be using the Node Version Manager.
1. Update the package repository
sudo apt update
2. Install NVM using either curl or wget command . (use eitehr one from below)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
wget -q0- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
3. Restart the terminal and run the folowing command to recognize the changes
source ~/.bashrc
4. Check if NVM is installed correctly
nvm --version
5. Check local node versions available
nvm ls
6. Check new versions availble online
nvm ls-remote
7. To install a specific version from the remote list you can use the following command sufixed with version
nvm install [version.number]
Update Node.js to Latest Version on Linux | Ubuntu