node.jsnvmnvm-windows

Set default node version


I am attempting to set the default version of node to 14 using the following commands

nvm install 14

nvm alias default 14

But I only get a list of available commands instead... enter image description here

running node --version returns v20.10.0, which is the version I installed, but I thought the install 14 command above should install 14, the setting alias default 14 would set the default to 14.

I tried following instructions above from here...

How can the default node version be set using NVM?


Solution

  • Looks like you are on Windows OS, in which case you probably use nvm-windows, and not the original nvm tool, which works only on POSIX type OS (i.e. Linux, macOS).

    nvm alias command only exists for the latter, there is no equivalent for nvm-windows.

    The SO post you refer to is about nvm for Linux.


    IIRC, nvm install with nvm-windows does not switch the current Node version; you have to explicitly call nvm use after installation.

    Furthermore, nvm-windows switches the Node version globally (using Windows PATH), so there is no point in having a default version.