How to install NodeJs and NPM?

Installing different versions of Nodejs on Mac OS or Ubuntu

When you are working on different nodejs based projects it is good idea to work with multiple nodejs versions. You can use nvm to manage different types of nodejs on your mac or linux machine.

Let's first install NVM (Node Version Manager) on our mac or linux machine using following tutorial:

How to Install NVM?

Once you have nvm installed on your machine let's now install nodejs and nvm. To check available nodejs version run following command on your terminal window.

nvm ls-remote

Install nodejs using nvm

Now to install nodejs pick the version you like to install and run following command on your terminal window:

# install v12.13
nvm install v12.13.1

# install v13.3
nvm install v13.3.0

Now, that you have multiple versions of nodejs each time you want to work with specific version of node js run following command to pick one you like:

nvm use v12.13.1

Above command will make v12.13.1 as a default node version. To uninstall specific node version you can run following command:

nvm uninstall v11.10.1

Install npm using nvm

To install npm version you like you can first check the installed version of nodejs and npm as below:

node --version
npm --version

To update current version of npm run following command:

# run with sudo if required
npm install -g npm@X.X.X​

I hope you like this tutorial please share your love and spread this post.