Steps are mentioned step by step:
1. sudo apt update
Now adding Node Version Manager for installing version specific nodejs. For doing that, following command is needed to be given:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
2. This will install the nvm script to your user account. To use it, you must first source your .bashrc file:
source ~/.bashrc
3. Now, you can ask NVM which versions of Node are available:
nvm list-remote
4. It’s a very long list! You can install a version of Node by typing any of the release versions you see. For instance, to get version v14.10.0, you can type:
nvm install v14.10.0
5. You can see the different versions you have installed by typing:
nvm list
Now you’ll be able to know your node version and npm version by following commands:
node -v
npm -v