[Issue]: `nvm use` bug
CholezYu opened this issue · 5 comments
What happened?
I switched versions with nvm use, and then the files in the nodejs folder were emptied, i.e. the association with nvm was gone. However, the files for each nodejs version in the nvm folder still exist.
This is the second time this has happened.
What did you expect to happen?
Everything works fine.
Version
1.1.11 or newer (Default)
Which version of Windows?
Windows 11+
Which locale?
None
Which shell are you running NVM4W in?
PowerShell
User Permissions?
Administrative Privileges, Elevated
Is Developer Mode enabled?
None
Relevant log/console output
No response
Debug Output
none.
Anything else?
No response
This is expected behavior. Yarn is a global module. When you switch versions, you get a clean/isolated instance of npm global modules, just like if you installed a new version of Node without using a version manager. You have to install the global modules in each version.
Some people coming from other version managers are used to having commands that auto-install global modules from one version into another version when they nvm install
a new version. This functionality will not be added to NVM4W, but it will be in Runtime.
I mean, I can make sure I have yarn, npm, etc installed in every node version and that they all work, but I was on a normal version switch and the nodejs folder became empty.
I remember when I installed nvm, the nodejs folder became a shortcut to a version of nvm, but now, it's a normal folder again, and it's empty.
This sounds like it could be a permissions issue. Run nvm debug
to confirm NVM4W's privileges.
NVM4W doesn't create folders for symlinks, so it sounds like you may have a conflicting process doing something to that folder. Once a true folder is created, mklink can no longer create a symlink. This can happen when people choose their installation path as the symlink path. Again, the output of nvm debug
would help identify if that is the problem.
Do you have anything else running that manages Node? The only other time I've seen something like this is when another tool is attempting to manage some part of the Node installation (ex: conda).
NVM4W does not create folders other than the installation root for Node, so it seems like something else is modifying the symlink path. Some other apps assume the path where node.exe exists is the authoritative source (i.e. they don't account for version managers).
Anyhow, to fix this, you just need to remove d:\nodejs
and re-run nvm use <whatever_Version_you_want>
. That should put NVM4W back into a working state. However; this could happen again if there is another app that tries to modify the symlink path.