DEV Community

Cover image for NVM set default version
Chris Bongers
Chris Bongers

Posted on • Originally published at daily-dev-tips.com

NVM set default version

In a previous article, we learned about NVM, a great way of managing multiple node versions on your machine.

However, you might have most projects running on a specific version of Node.
In that case, setting your default NVM version to this Node version might make sense.

Setting a default NVM version

To set the default NVM version, you first have to make sure that version is installed in NVM.

As a reminder, you can install a version like this:

nvm install 16
Enter fullscreen mode Exit fullscreen mode

We can then run the following command to set this as our default version.

nvm alias default 16
Enter fullscreen mode Exit fullscreen mode

Remember, this is one specific query on a version type you can install.
Some valid alternatives are:

nvm alias default 16

nvm alias default lts

nvm alias default 12.14.3
Enter fullscreen mode Exit fullscreen mode

You can check which versions you have installed by running the following command.

nvm ls
Enter fullscreen mode Exit fullscreen mode

This will return a list of all the versions you have installed already.

Returning to the system version

Perhaps at one stage, you might want to change to whatever your system uses.

We can run the following command to do that:

nvm alias default system
Enter fullscreen mode Exit fullscreen mode

Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Top comments (2)

Collapse
 
waylonwalker profile image
Waylon Walker

I like how nvm can just install 16 and it leverages semver to get the lastest version that matched. It would be nice if pyenv did this, rather than requiring an exact version.

Collapse
 
dailydevtips1 profile image
Chris Bongers

Yes 100%, although found myself moving away from LTS at the moment, just because it doesn't play nicely with all packages 😅