Npm is the package manager for Node.js. In this tutorial, I will show you how to install a different version of node js on ubuntu.
sudo apt-get install build-essential apt-transport-https curl
#Installing Node.js and npm from Node Source
You can install any node js version by the setup_xx.x.
The command will add the Node Source signing key to your system, create an apt sources repository file, install all necessary packages and refresh the apt cache.
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash
After that, you need to hit the following command.
sudo apt install nodejs
Finally, you can check the node js and npm version by hitting the following commands.