There are a couple of ways through which you can download, install, and then use Node.js on your computer. There are tools like nvm, asdf, nodenv, n that you can use to manage your Node.js version.
Let’s discuss the Node.js version control manager n that I personally recommend and use.
n is a Node.js version management tool with no subshell, no profile setup, no convoluted API, etc. You can just install and install it. Simple!
If you have already installed Node.js and now want to use n to version control it then you can download n with npm. Just copy-paste the following command in your terminal and press the Enter key.
npm i -g n
If you haven’t installed Node, you can use Homebrew or Curl to install n. If you are going with Homebrew, just run the following command in your terminal.
brew install n
But if you want to use curl, then you can run this command:
curl -L https://git.io/n-install | bash
Since now you have installed n on your computer, let’s try it out. If you are interested in installing the latest version, just run the following command in your terminal.
n latest
It will go ahead and install the Current version of Node.js.
Now if you are interested in installing the latest LTS version then go ahead and run the following command in your terminal.
n lts
Now if you want to install any particular version of Node.js, you can easily do it. Just run the following command with your version number.
n $version
This command will also switch your Node.js version to the version you just downloaded. You can go back to your latest Current version by just typing the following in the terminal.
n current
If you want to see all the Node.js versions you have installed, just type in the following in your terminal.
n
You can read the detailed documentation here.
I like working with n because with this version control manager, I don’t have to add anything to my bash profile. And because of this, my terminal does not slow down. You should definitely give it a shot if you are looking for a decent Node.js version manager.