# NOTE: apt does not have newer versions of npm
# For node version 16:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
# See for the latest version https://github.com/nodesource/distributions/blob/master/README.md#debinstall
# assuming you have curl installed
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
# To Check the node version
node -v
# Installing specific version ===> change setup_16.x to setup_14.x or any other.
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
# If error like this occurs.
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_16.16.0-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
#Solution:( replace nodejs_12.20.0 ==> the version you want to install)
sudo dpkg -i --force-overwrite /var/cache/apt/archives/nodejs_12.20.0-deb-1nodesource1_amd64.deb
sudo apt -f install