There are several ways to install Node and npm on Ubuntu and it can be found here. I prefer using the third option which was using the Node Version Manager. Complete instructions for NVM can be found here.
Run either one of these commands:
1link$curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
2link$
3link$wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Depending on the shell you are using, run of these commands:
1link$source ~/.bashrc # --> bash
2link$source ~/.zshrc # --> zsh
3link$. ~/.profile # --> ksh
1link$nvm -v
0.39.0 # --> or whatever the latest version is
List the available versions
1link$nvm list-remote
...
v15.14.0
v16.0.0
v16.1.0
v16.2.0
Select your desired version
1link$nvm install v16.2.0
Check your Node.js and npm versions
1link$node -v
v16.2.02link$npm -v
0.39.0