Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nvm use does not switch node versions

Tags:

nvm

on a Windows 10 machine and using nvm4w I tried:

from the above image:

  • node --version to check the current version
  • nvm list to list installed versions
  • nvm use 8.8.1 so we switch from 6 to 8
  • nvm on to enable it
  • node --version to re-check the node version

what am I doing wrong?

like image 476
balexandre Avatar asked Oct 30 '17 14:10

balexandre


People also ask

How do I change node version using NVM?

Switching among Node. 7; we can simply run either nvm use 12.22. 7 or nvm use 16.13. 0 to easily switch into either version we need. Note that since we only have one version that begins with 12, 14, or 16, we can switch versions with a simple nvm use 16 , nvm use 14 , or nvm use 12 command.

How do I use multiple node versions in NVM?

Switching Between Versions So if you install the latest Node. js version, and run node -v right after, you'll see the latest version output. To switch through installed versions, nvm provides the nvm use command. This works similarly to the install command.

Can I change npm version with NVM?

You can install two versions of Node. js using nvm, and install different version of npm on each Node. js environment. For example, nvm install 14.18.

How do I switch node versions?

To change Node. JS versions, we have to first download the version we want. Make sure you have nvm installed first. If you don't know the version you want to install, type nvm ls-remote to get a full list of all installable Node.


2 Answers

I had to delete the folder located at C:\Program Files\nodejs:

enter image description here

And then run nvm use {version} again to repopulate this folder with the correct node version.

I suspect that in some cases nvm is having trouble deleting this folder for some reason.

like image 109
Dustin Spengler Avatar answered Sep 20 '22 18:09

Dustin Spengler


So I found a workaround.

I renamed C:\Program Files\nodejs to C:\Program Files\nodejsx

and then running nvm use versionNumber works fine.

Seems like nvm cannot change it to a symlink and fails silently.

like image 38
Shuvo Avatar answered Sep 21 '22 18:09

Shuvo