nvm-windows
nvm-windows copied to clipboard
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
-
[x] Windows Server 2012
-
[ ] Windows Server 2012 R2
-
[ ] Windows Server 2016
-
[x] My Windows installation is non-English.
I'm using NVM4W version:
- [x] 1.1.6
- [x] 1.1.5
- [ ] 1.1.4
- [ ] 1.1.3
- [ ] 1.1.2
- [ ] 1.1.1
- [ ] Older
- [ ] OTHER (Please Specify)
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.
- [x] verified I'm using an account with administrative privileges.
- [x] searched the issues (open and closed) to make sure this isn't a duplicate.
- [x] 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+?)
- [x] 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.0nvm use 10.0.0nvm install 9.11.1nvm use 9.11.1
I've found the problem. For some reason it installed node v10.0.0 under C:\nodejs but doesn't do the same for v9.11.1.
I have the following configuration:
C:\nodejs: symlink toC:\nvm\v10.0.0(??)C:\Program Files\nodejs: symlink toC:\nvm\v9.11.1C:\nvm\v9.11.1:v9.11.1
I'm not sure why it updated C:\nodejs (the one I'm using on my CI) to v10.0.0 and now it doesn't change it back to v9.11.1 when using the nvm use command.
EDIT: I think nvm used c:\nodejs in earlier versions as %NVM_SYMLINK%, and more recent versions (probably since 1.1.6) uses c:\program files\nodejs.
So, restarting the shell just updates the NVM_SYMLINK environment variable and we're set.
In my case, I also had to restart applications (Jenkins for exemple) to apply the change.
If that is the case - default nvm installation directory changed - it would have been nice to be notified in the release notes. When I updated nvm I just kept the default node location when prompted.
Or read %NVM_SYMLINK% during the nvm setup, to avoid changing directories without notice.
Can confirm this issue. Unable to downgrade to node 8.
I restarted the shell and it still doesn't work. Also, I cannot uninstall v10 (it says it's not installed)

@mohamed3on Can you check your environment variables? Look for NVM_SYMLINK
@Mohamed3on could you try this pre-release version https://github.com/b-dur/nvm-windows/releases/tag/1.1.7 to see if it solves the problem?
Recommended to uninstall your current NVM. Then install version 1.1.7. Restart your Bash/shell/cmd/terminal etc.
I uninstalled nvm and then installed the new 1.1.7 version. Then I could install node 10.1.0 but that version downloaded and installed npm 5.6.0 which is too old. That may be another problem though.
@jbergens good to know that you could install node 10.1.0.
I quickly looked into where the npm version comes from. NVM fetches the info from https://nodejs.org/dist/index.json and extract the versions. Can see in the list that node 10.1.0 is registered with npm 5.6.0.
However there is a problem ATM with upgrading npm locally.
As far as I can see, these problems, in combination, is currently a showstopper. nvm can not be used to install the latest (10+) versions of node and npm. And npm can not be updated (easily) when installing node via nvm. Which indeed makes nvm unusable for lots of peope, e.g. me :)
Does anyone know why https://nodejs.org/dist/index.json (and http://nodejs.org/dist/index.tab) features such old versions of npm? Is it a bug, or by design?
And given that it is so, how can we fix it? Either make sure that node-installation comes with a recent npm, or make updating npm work?
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.
@tsauvajon thanks for replying. This doesn't work for me, if I understand you correct.
C:\>echo %NVM_SYMLINK%
C:\Program Files\nodejs
C:\>where node
C:\Program Files\nodejs\node.exe
C:\>nvm list
* 10.2.1 (Currently using 64-bit executable)
10.1.0
9.11.1
C:\>npm --version
npm WARN npm npm does not support Node.js v10.2.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
5.6.0
C:\>npm -g i npm
npm WARN npm npm does not support Node.js v10.2.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN npm npm does not support Node.js v10.2.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! path C:\Program Files\nodejs\npm.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npm.cmd
npm ERR! Move it away, and try again.
C:\>
Did you have a different experience, or did I misunderstand?
Oh actually your node installation is working correctly but npm won't install npm, I misunderstood your problem.
I had similar incompatibilities when upgrading to node 10.x, I had to roll back to 9.x.
I think this is a node / npm problem, not a nvm problem. Do you have a different experience when installing node 10 manually ? I haven't taken the time to investigate anything, I just went back to v9.x for now, with all these warnings (it looks like v10 isn't supported by npm / yarn yet for some reason).
I think this is a node problem (node ships with incompatible npm version -- how is this possible!?), which in combination with the nvm problem (can't upgrade npm) makes nvm unusable for latest node versions. Is this the correct understanding?
Last time I installed node 10+ manually I believe I was able to update npm, but I may remember wrong.
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 & npm -v & yarn -v &
Thanks! That worked for me :)
My situation is like this, the current version of node is 16, and the use of version 14 is invalid.
$ nvm current
v16.20.0
$ nvm use 14.18.2
Now using node v14.18.2 (64-bit)
$ nvm current
v16.20.0
It was later discovered that after reinstalling nvm-windows v1.1.11, there were two symbolic links.
$ where node
C:\nodejs\node.exe
C:\Program Files\nodejs\node.exe
After checking the file properties, it is found that the symbolic link of C:\nodejs\ points to version 16, and the symbolic link of C:\Program Files\nodejs\ points to version 14.
Later, after I deleted C:\nodejs\node.exe, the node version in the environment can be displayed normally.
$ nvm current
v14.18.2
As @tsauvajon said, recently the new version uses the symbolic link of C:\Program Files\nodejs\, and the symbolic link of the old version has not been cleared, resulting in the node version not being able to switch normally.
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).