'How can I set the default Node.js version with nvm? [duplicate]

I'm using nvm to manage my Node.js versions. In my projects, I have .nvmrc files in the project root. When I run nvm use, I get the Node.js version needed for the project.

This is all working great, but when I open up a new console window, at first I always have a very old Node.js version set automatically.

Running node -v gives me 6.9.5.

What's really annoying is that my IDE (IntelliJ IDEA) runs pre-commit hooks when I use its VCS commit dialog using this old Node.js version, which makes unit tests and the commit fail.

How can I make it so that a specific version of Node.js is set as default?



Solution 1:[1]

You can use the command nvm alias to set the default version you would like to use, for example:

nvm install 10.17.0
nvm alias default 10.17.0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Penny Liu