'Can't set default node version in NVM

I can't set the default version in NVM. I always get this warning: Version xx.xx.x does not exist. no matter what I type. I am on Ubuntu 18.04 and have ZSH installed with the script. This is what I get when I do nvm list :

->       system
default -> 10.15.3 (-> N/A)
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
lts/ -> lts/dubnium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.0 (-> N/A)
lts/dubnium -> v10.15.3 (-> N/A)


Solution 1:[1]

You first need to install a node version that will be set as your default version. Use nvm list to get the full list of available versions and use nvm install to install it. Use nvm install node for the latest version.

Solution 2:[2]

You should first install your node version.

Supposing it's the latest stable version (in March 2022 is 16.14.0) you should do

nvm install 16.14.0

Then, check if version was successfully installed with

nvm list

And finally, set the default version with

nvm alias default 16.14.0

Now you are ready to go

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 Raphael Valois
Solution 2 Gabriel Arruda