Install Node.js and npm using Node Version Manager NVM
Open your terminal and run this NVM Node Version Manager installation script.
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Or you can install with cURL
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
In this script v0.35.3 is nvm version number. you can chnage this based on the latest nvm version.
Close your terminal and open again. Now run this to verify the nvm installation.
Install Node.js and npm:
You can install the latest version of Node.js by running this command.
nvm install node
If you want to install the specific node.js version, use this command first to find the available Node versions.
Then install with this command, if you want to install v12.16.2
nvm install 12.16.2
List the installed node versions. Close and open your terminal and then run.
You can set the default Node.js version by running this command. Just chenage below command with your version number.
nvm use v12.16.2
You can verify your default version by this command.
You can uninstall specific version of node.js by this command. Here i am uninstalling v13.13.0 from my system.
nvm uninstall v13.13.0
npm is comes with node.js. when you download and install Node.js, then you automatically installed npm on your system. you can check the installed npm version with this command.