nvm-windows: Can't switch node versions from 10.0.0

My Environment

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

  • Windows 8

  • Windows 8.1

  • Windows 10

  • Windows 10 IoT Core

  • Windows Server 2012

  • Windows Server 2012 R2

  • Windows Server 2016

  • My Windows installation is non-English.

I’m using NVM4W version:

  • 1.1.6
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • Older
  • OTHER (Please Specify)

I have already…

  • read the README to be aware of npm gotchas & antivirus issues.
  • 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

nvm use 9.11.1 should change from version 10.0.0 to 9.11.1

Actual Behavior

>node -v
v10.0.0

>nvm use 9.11.1
Now using node v9.11.1 (64-bit)

>node -v
v10.0.0

>nvm version
1.1.6

>nvm list
  * 10.0.0 (Currently using 64-bit executable)
    9.11.1

It works correctly on my local machine (Windows 7) but doesn’t work on my CI Server (Windows 2012), which is very problematic as it breaks some builds. I’ve tried nvm versions 1.1.5 and 1.1.6. I had no problem switching from node version 9.11.1 to 10.0.0, but it doesn’t seem to work the other way around.

Steps to reproduce the problem:

On a Windows 2012 Administration Command Prompt:

  • nvm install 10.0.0
  • nvm use 10.0.0
  • nvm install 9.11.1
  • nvm use 9.11.1

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 16 (5 by maintainers)

Most upvoted comments

I believe everything from the original issue has been resolved in newer versions (this was originally filed for NVM4W 1.1.5/6), so I am closing this. It would be best to open another issue if this persists in modern versions.

In NVM4W 1.1.11, there is a nvm debug command. It runs a check to determine whether NVM is in the correct location within your PATH. The case of having NVM4W install in a new location (essentially installed twice) was not one I thought of when adding the debug command, so I’ve added that to my backlog.

To avoid the situation described by @lpreterite, either make sure you use the same installation paths when you upgrade, or use the special upgrade tool packaged in the release (which only upgrades the release assets, not the environment variables or settings files).

After some research I’ve found a way to update npm. You have to move out of the default repository for some reason.

With nvm, the binaries will be installed at %NVM_SYMLINK%. Npm and yarn won’t be able to write under this folder if installed under C:/Program Files, because of Windows rules I guess.

If you want to either:

  • update npm
  • install global packages with yarn you will have to change where the binaries are installed or change where nvm will install node, out of c:/program files.

Note: I didn’t test this, and maybe it is not related with Program Files. But I successfully update npm by changing the binaries folder: npm config set prefix "c:/npm"

My solution has been to create an update script:

@echo off
nvm install $1
nvm use $1
node -v > tmpFile
set /p node_version= < tmpFile
del tmpFile
setx node_version %node_version% /m
 -- be careful with long paths, maybe do it manually instead ?
setx path "%path%;%appdata%\nvm\%node_version%;%appdata%\nvm\%node_version%/bin" /m
"%nvm_home%/%node_version%/npm" config set prefix "%appdata%\nvm\%node_version%"
"%nvm_home%/%node_version%/npm" i -g yarn npm
yarn config set prefix "%appdata%\nvm\%node_version%"
echo installed node, npm and yarn
node -v &amp; npm -v &amp; yarn -v &amp;

How to fix:

Open a new cmd shell and run

echo %NVM_SYMLINK%
where node

If node is located under the symlink location (e.g. in my case NM_SYMLINK = C:\Program Files\nodejs and node is located at C:\Program Files\nodejs\node.exe, it should be OK. Just restart your computer and everything should work fine.

If nodejs is located somewhere else (eg: C:\nodejs\node.exe), just delete the containing “directory”, which is actually just a symlink. In my case, I would open an explorer, navigate to C:\, right click on the nodejs symlink (the default icon is a folder icon with an arrow on it) and delete it. You can also do that by command line: rmdir c:\nodejs (or whatever your old symlink was - note: I haven’t tested this). Now restart your computer, re install and use the desired node version with nvm and you should be good to go.