in my opinion, the bast way to install Node Js and Npm on Linux and Mac Os system is with some sort of node package manager. in this tutorial we will use nvm, you can follow their tutorial on GitHub or continue with us.
check for updates:
run the two following commands
sudo apt update && sudo apt upgrade
run one of the following install script commands
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
now run these to commands to finish the installation.
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
verify the installation
command -v nvm
install node
nvm install node
every thing should be ready by now, for more information please check nvms GitHub.