Nvm-windows: Why doesnt work to switch node version via "nvm use"

Created on 11 Dec 2017  路  43Comments  路  Source: coreybutler/nvm-windows

If this is a question about how to use NVM4W, please use stackoverflow instead.

If this is an issue regarding antivirus, make sure you search the existing issues first.

My Environment

  • [x] Windows 7 or below (not truly supported due to EOL - see wiki for details)

I'm using NVM4W version:

  • [x] 1.1.6

I have already...

  • [x] read the README to be aware of npm gotchas & antivirus issues.
  • [x] reviewed the wiki to make sure my issue hasn't already been resolved.
  • [ ] verified I'm using an account with administrative privileges.
  • [ ] searched the issues (open and closed) to make sure this isn't a duplicate.
  • [ ] made sure this isn't a question about how to use NVM for Windows, since gitter is used for questions and comments.

My issue is related to (check only those which apply):

  • [ ] settings.txt
  • [ ] proxy support (Have you tried version 1.1.0+?)
  • [ ] 32 or 64 bit support (Have you tried version 1.1.3+?)
  • [ ] Character escaping (Have you tried version 1.1.6+?)
  • [ ] A standard shell environment (terminal/powershell)
  • [ ] A non-standard shell environment (Cmder, Hyper, Cygwin, git)

Expected Behavior

i tried to switch v8.9.1 to 6.12.0 (node version)

Actual Behavior

but, it didnt switch to 6.12.0 or another versions.
(i installed 8.9.1 at last)

Steps to reproduce the problem:

i opened cmd via administrator.

C:Windowssystem32>nvm ls

  • 8.9.1 (Currently using 64-bit executable)
    7.1.0
    6.12.0

C:Windowssystem32>node -v
v8.9.1

C:Windowssystem32>nvm use 6.12.0
Now using node v6.12.0 (64-bit)

C:Windowssystem32>node -v
v8.9.1

C:Windowssystem32>nvm ls

  • 8.9.1 (Currently using 64-bit executable)
    7.1.0
    6.12.0

Most helpful comment

Workaround:
Renamed "C:Program Filesnodejs" to "C:Program Filesnodejsx",
Then from an elevated cmd called "nvm use 8.9.1" (any version you got should work..) and it started to work.
Problem seems to be if nodejs directory exists, nvm can not change it to a symlink and 'fails silently' would be nice with a fail and an error message stating the problem.

All 43 comments

the same

+1

Same with nvm 1.1.5 :

C:\windows\system32>nvm version
1.1.5

C:\windows\system32>nvm ls

    8.9.2
  * 4.7.2 (Currently using 64-bit executable)

C:\windows\system32>nvm use 8.9.2
Now using node v8.9.2 (64-bit)

C:\windows\system32>node -v
v4.7.2

C:\windows\system32>

@biologeek same thing :/
did you find some solution ?

This occurs most often due to use of an unprivileged user account. Your account must have administrator-level permissions, because Windows requires it for symlinks. nvm use creates a symlink to the appropriate Node installation. If your symlink exists within C:\Program Files, you'll need elevated permissions (nvm4w will attempt to do this for you automatically).

I am admin on my pc. Though I could overcome this issue by manually renaming folders so that nvm symlink points to the version I need.
Quick and dirty but no need to have admin access !

@biologeek - you still need admin access to rename directories within C:\Program Files because it is a protected directory on Windows (same is true for C:\windows\system32). Personally, I keep my NVM4W symlink in my user directory so this isn't an issue.

+1 on this issue: I can't change the version.

Workaround:
Renamed "C:Program Filesnodejs" to "C:Program Filesnodejsx",
Then from an elevated cmd called "nvm use 8.9.1" (any version you got should work..) and it started to work.
Problem seems to be if nodejs directory exists, nvm can not change it to a symlink and 'fails silently' would be nice with a fail and an error message stating the problem.

Can confirm what @ituasdu said. Thanks!

@ituasdu solved my problem锛宼hx

Hi, same issue here.

NVM creates a a symlink to the installed node version.

The problem is that Windows 7 requires admin right levels to create a symlink, and it's not the case anymore in Windows 10.

A workaround is to use junctions ('hard' links) on Windows 7 with the parameter '/J'. Junctions don't require admin rights levels and a low privileges user accounts as mine can use it. Example:

nvm install 8.11.2
mklink /D /J node C:\PATH_TO_NVM\nvm\v8.11.2

Question: Wouldn't it be a good idea to use junctions instead of symlinks ? Or at least specify a option to nvm eg '--junctions' ?

I'm thinking about creating a pull request for this as it's blocking for my company. Would it be helpful ?

@nan0 making a junction on windows 7 isn't working... it still won't switch versions.

C:\Program Files\nodejs contains v6.9.4 (installed before NVM4W installed).

C:\Users\[user]\AppData\Roaming\nvm contains v6.9.4\ and v8.11.3\

I ran the command you provided in your post:

Issue 1:
mklink /D /J node C:\Users\[user]\AppData\Roaming\nvm\v8.11.3 when I try to do it for v6.9.4 it says "Cannot create a file when that file already exists."

Issue 2:
Also, using nvm use v8.11.3 then nvm list it doesn't indicate that it actually is using either nvm installed node version.

Is there anything else that can be done?
How can I see the junctions that are created? Where do they actually exist?

I'm using:
Windows 7. no admin rights allowed for my user.

never mind it does work. I realized that I was making the junction in the wrong folder.

renaming C:Program Filesnodejs to C:Program Files nodejsx
and then making the junction as "nodejs" and pointing it to C:\Users\[user]\AppData\Roaming\nvm\v8.11.3 worked!

So to sum up the solution is this:

with no stand alone node installed.

In the C:\Program Files\ folder use cmd to run mklink /D /J nodejs C:\Users\[user]\AppData\Roaming\nvm\v8.11.3

For those interested in contributing, thank you!

However; I want to point out that junctions were explicitly avoided because they will not work across different hard drives. This was a particular sore spot in enterprise networks with shared drives/mapped drives.

@ituasdu It solved my problem,
Thanks for the solution.

My computer is Windows 7, and I have administrator privileges. In the same situation, NVM cannot change version.My approach is to set up NVM_SYMLINK D:Project NVM v8.11.4 in the environment variable.Switching node versions only requires changing the version number corresponding to the environment variable NVM path, such as: NVM_SYMLINK D:Project NVM v6.9.0.In this way, although the problem was solved, every time I changed the version, it was troublesome, and I did not find a better solution for the moment.

The solution of "Sagan" from stack overflow works for me:
https://stackoverflow.com/questions/28313372/nvm-for-windows-not-working

For me,

nvm list 

image

Then I remove v8.9.4 folder out of nvm.
image

After that:

nvm list 

image

Then, I move v8.9.4 back.

This is happening for me on Windows 10 10.0.17134.165
I tried the solution mentioned by @ituasdu and it worked. thank you!!!

If you found that after you try cmd like:
nvm use 6.10.0
and nodejs version has not been changed, you can start cmd.exe or powershell by administrator.
image

I had the same problem when switching between node 6.6.0 and 7.9.0 (Windows 10) but ituasdu's solution wasn't working. Re-installing nvm didn't work either.

I ran nvm install latest (installed 11.3.0) and this somehow fixed it for me.

Workaround:
Renamed "C:Program Filesnodejs" to "C:Program Filesnodejsx",
Then from an elevated cmd called "nvm use 8.9.1" (any version you got should work..) and it started to work.
Problem seems to be if nodejs directory exists, nvm can not change it to a symlink and 'fails silently' would be nice with a fail and an error message stating the problem.

This worked for me.
image

PS > nvm use 11.4.0
Now using node v11.4.0 (64-bit)
PS > node -v
v10.11.0
PS > nvm use 11.4.0
Now using node v11.4.0 (64-bit)
PS > node -v
v11.4.0

@ituasdu worked for me too.. thanks.. :)

@ituasdu Thanks, worked like a charm. I believe this happens when people have NodeJS installed previously directly without nvm and then try to use node through nvm.

This also works for me, thanks.

I don't know if this could drop some light to the issue but in my case I think this had happen after install a new version of node without nvm (manually). Seems that this action makes crazy nvm.

@coreybutler any thoughts on installing the symlink on a folder that doesn't require admin privs? I know this might be slightly, bad form in Windows dev, but it will definitely side-step all of these issues, especially in a highly-locked-down, enterprise environment where getting admin privs is a huge pain.

Other pain is what I am currently suffering through (not because of nvmw) where, although I do indeed have admin privs in some instances, every time I want to switch between versions of node, I have to open up a whole other cmd window, run cmd as admin and finally run nvm use 10.15.1 (for example). then nav back to my dev, cmd window. argh. again, pain due to work env not because of nvmw. (nvmw is awesome btw).

just a thought. ;-)

Run nvm use <node.js version you want to use> (e.g. nvm use 10.15.3) under Powershell ISE as Administrator resolved the issue in my Windows 10.

I have to run nvm use any.version multiple times under Powershell As Administrator to get it to work. It randomly changes version at the first, second or third attempt (nvm version 1.1.7).

I tried to fix it by installing Link Shell Extension and doing the following steps:

  1. right click on C:\Program Files\nodejs
  2. select _Pick Link Source_
  3. right click on C:\Program Files
  4. select _Drop as..._ > _Symbolic Link_
  5. rename nodejs - SymbolicLink to nodejsx

But unfortunately the problem is still occurring.

Can confirm @ituasdu solution worked for me also.

@ituasdu works for me, thnks.

@monico-moreno - next time ping me via email when I don't respond for months at a time :) To answer your question, you can install to any folder you want using the installer. However; all symlinks on Windows require admin privileges, except for some developer modes on newer editions of Windows 10. Bottom line is admin privileges come into play at some point.

Also, maybe you can beta test the menu system when I wrap it up (switch versions from the Windows task bar). Would that be a better workflow?

  • Open control panel and uninstall nvm and node.
  • install nvm-setup.zip from https://github.com/coreybutler/nvm-windows/releases
  • open command prompt. Enter nvm install @version. then nvm use version.
  • install yarn. then in command prompt run yarn install or yarn.
  • check the node version by node -v.

I just had similar issue, but different reason.

D:\> node -v
v12.14.0
D:\> nvm use 8.9.4
Now using node v8.9.4 (64-bit)
D:\> node -v
v12.14.0

// problem
D:\> where node
D:\soft\nodejs\node.exe // <- old nvm used this one
C:\Program Files\nodejs\node.exe // <- new nvm was changing this one

IIRC I had previous nvm version installed to D:soft and it was changing link D:softnodejs. At some point old nvm stopped working, because npm repository changed location (if it works - don't touch, please). I had to install new nvm, and I guess new nvm refused to change old link, instead it was updating link C:Program Filesnodejs. So I removed D:softnodejs and it was fixed.

Thanks to @delepster who suggested to uninstall old node, that helped me to spot the problem

we installed on three computers today, two of them windows 10 operating system installed and one with windows server. Both machines with windows 10 OS lost their search at startup features but not the one with Windows Server OS. so, you can not type the name of the program you want and see anymore.

Anyone else having the same issue?

@putko this is a windows issue appeared today, confirmed and fixed by MS. see this tweet https://twitter.com/tomwarren/status/1225110095010418689

Workaround:
Renamed "C:Program Filesnodejs" to "C:Program Filesnodejsx",
Then from an elevated cmd called "nvm use 8.9.1" (any version you got should work..) and it started to work.
Problem seems to be if nodejs directory exists, nvm can not change it to a symlink and 'fails silently' would be nice with a fail and an error message stating the problem.

This worked for me.
image

PS > nvm use 11.4.0
Now using node v11.4.0 (64-bit)
PS > node -v
v10.11.0
PS > nvm use 11.4.0
Now using node v11.4.0 (64-bit)
PS > node -v
v11.4.0

This worked for me too.

Had a similar problem with 1.1.7, finally figured out that the settings.txt file is ignored. nvm use would do absolutely nothing, until I manually set NVM_SYMLINK. Also, without SYMLINK set, nvm will try to remove ., which is interesting, to say the least.

The path parameter in the settings.txt, which contains what should be used by default as SymLink, is never read or used to initialize:
https://github.com/coreybutler/nvm-windows/blob/88353cfcea140e02e2b13584fd89454adc9f52b3/src/nvm.go#L727-L751

Latest version of Windows 10 Pro where I went through a fresh install I encountered the same issue.

My usual steps to setting up my machine is:

  1. Install primary dependencies (NodeJS and Docker)
  2. Install IDE (Visual Studio 2019 at this point with .NET, NodeJS and Python development deps)
  3. Install additional dependencies like Windows Terminal, PL fonts, nvm, tmux, WSL2, etc...

@ituasdu is correct in his assertion, when I renamed my nodejs file it allowed me to use nvm use and actually set it. Otherwise it would succeed falsely and tell me version set and so forth but it didn't set the version and I'm stuck with the LTS that was installed initially.

I know there is actually a line saying we should uninstall the existing node that I missed the first time around on the README.md but having used nvm-windows before I didn't check it again I just installed it via chocolatey and forgot about that. (is it possible to just do the npm uninstall as part of the install for chocolatey or to just detect if there is one and to prompt the user to uninstall it first before allowing them to install nvm?)

(is it possible to just do the npm uninstall as part of the install for chocolatey or to just detect if there is one and to prompt the user to uninstall it first before allowing them to install nvm?)

I think it is possible: this request should be made to the Chocolatey nvm package maintainer.

It happens when you have Node separately installed on your machine (from website or package manager). Uninstalling them and installing through nvm should solve the problem.

I'm having same problem and using PS in admin mode doesn't resolve the issue. (Windows 10.0.18363)

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

webspecialist picture webspecialist  路  5Comments

fredericrous picture fredericrous  路  3Comments

SufyanParkar picture SufyanParkar  路  4Comments

David263 picture David263  路  3Comments

Miggleness picture Miggleness  路  6Comments