node.js Windows 版 NVM 不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28313372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NVM for Windows not working?
提问by Felix
采纳答案by mscdex
Most likely what is happening is that the system %PATH%is being updated outside of the command prompt instance. Only opening a new command prompt will pick up these new external changes.
最有可能发生的情况是系统%PATH%正在命令提示符实例之外更新。只有打开新的命令提示符才会获取这些新的外部更改。
回答by Sagan
First examine your actual "C:\Program Files\nodejs" directory. Most of us already have a "nodejs" directory from a prior install, before we decided (or were told) to install nvm.
首先检查您的实际“C:\Program Files\nodejs”目录。在我们决定(或被告知)安装 nvm 之前,我们中的大多数人已经有一个来自先前安装的“nodejs”目录。
In the end, this "C:\Program Files\nodejs" directory will actually be a shortcut to where nvm manages the versions it installs (see C:\Users\xxx\AppData\Roaming\nvm). It seems that nvm is simply switching the shortcut, when we call "nvm use ...".
最后,这个“C:\Program Files\nodejs”目录实际上是 nvm 管理它安装的版本的快捷方式(参见 C:\Users\xxx\AppData\Roaming\nvm)。当我们调用“nvm use ...”时,似乎nvm只是简单地切换快捷方式。
Ok, so here is what I did to fix the situation where "nvm use ..." was not taking effect.
好的,这就是我为解决“nvm use ...”未生效的情况所做的工作。
- Delete/remove/uninstall the version of node in your "C:\Program Files\nodejs" directory. To the point where there is no more "nodejs" directory at all.
- Delete the existence of nvm (C:\Users\xxx\AppData\Roaming\nvm), basically, manually delete the nvm dir.
- Download your desired version of nvm (https://github.com/coreybutler/nvm-windows/releases)
- Open a CMD prompt (run as administrator), and install the downloaded version of nvm, nvm-setup.exe, from within this CMD command prompt.
- From within the admin level command prompt, run "nvm install 7.2.1", or whatever node version you want to install. Probably you will be installing multiple versions, so repeat as needed.
- Now do the usual "nvm use ...", "nvm list", etc...
- 删除/移除/卸载“C:\Program Files\nodejs”目录中的节点版本。到根本没有更多“nodejs”目录的地步。
- 删除nvm(C:\Users\xxx\AppData\Roaming\nvm)的存在,基本上,手动删除nvm目录。
- 下载您想要的 nvm 版本(https://github.com/coreybutler/nvm-windows/releases)
- 打开 CMD 提示符(以管理员身份运行),并从该 CMD 命令提示符中安装下载的 nvm 版本 nvm-setup.exe。
- 在管理员级别的命令提示符下,运行“nvm install 7.2.1”或您想要安装的任何节点版本。可能您将安装多个版本,因此请根据需要重复。
- 现在做通常的“nvm use ...”、“nvm list”等......
I dont know if this is the best way, but it worked for me...
我不知道这是否是最好的方法,但它对我有用......
回答by Jash
Having the same issue after installing latest node with nvm. nodecommand was not recognized in console. Closing and opening command windows did not work. checked nvm archto which the response is
使用 nvm 安装最新节点后遇到同样的问题。node控制台无法识别命令。关闭和打开命令窗口不起作用。检查nvm arch响应是
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: -bit.
Had to set the node again with arch setting
必须使用拱形设置再次设置节点
C:\WINDOWS\system32> nvm use 7.4.0 x64
Now using node v7.4.0 (64-bit)
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: 64-bit.
C:\WINDOWS\system32> nvm list
* 7.4.0 (Currently using 64-bit executable)
4.5.0
C:\WINDOWS\system32> node -v
v7.4.0
回答by Troglo
I had the same problem in Windows 10, and the solution for me was in @pleverett answer in https://github.com/coreybutler/nvm-windows/issues/191
我在 Windows 10 中遇到了同样的问题,我的解决方案是在https://github.com/coreybutler/nvm-windows/issues/191中的 @pleverett 答案中
Symptoms: no bit architecture and no default version
症状:无位架构,无默认版本
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: -bit.
C:\WINDOWS\system32> nvm list
8.9.4
6.13.0
Solution: After uninstalling node, make sure the directory where node was originally installed has been removed and not just empty. For Windows 7 ad 10, 64-bit, the default is "C:\Program Files\nodejs".
解决方法:卸载node后,确保node原来安装的目录已经被删除,而不是空的。对于 64 位 Windows 7 ad 10,默认值为“C:\Program Files\nodejs”。
If the "nodejs" directory still exists then the "nvm use" command can't make the symbolic link to the node version under nvm's control.
如果“nodejs”目录仍然存在,则“nvm use”命令无法建立指向nvm控制下的节点版本的符号链接。
I had the same problem until I manually deleted the "nodejs" directory.
在我手动删除“nodejs”目录之前,我遇到了同样的问题。
回答by Subham Goyal
Rename "C:\Program Files\nodejs"to "C:\Program Files\nodejsx"
重命名"C:\Program Files\nodejs"为"C:\Program Files\nodejsx"
nvm use x.x.x
This worked for me. Maybe it will work for you too.
这对我有用。也许它也适合你。
回答by giraffe.guru
In my case I was using git bash -- switching to cmd.exe worked.
就我而言,我使用的是 git bash——切换到 cmd.exe 工作。
More suggestions at: https://github.com/coreybutler/nvm-windows/issues/58
更多建议请访问:https: //github.com/coreybutler/nvm-windows/issues/58
回答by xianshenglu
For me,
为了我,
nvm list
nvm list


Then I remove v8.9.4folder out of nvm.
然后我从nvm 中删除了v8.9.4文件夹。


After that:
在那之后:
nvm list
nvm list


Then, I move v8.9.4back.
然后,我将 v8.9.4 移回原处。
回答by Adam Orlov
- Make sure you delete all old nodejs.
- Install nvm
- Install node
- run 'nvm on'
- run 'nvm list'
- run 'node --version'
- 确保删除所有旧的 nodejs。
- 安装 nvm
- 安装节点
- 运行“nvm on”
- 运行'nvm列表'
- 运行“节点 --version”
回答by aberk-udsMoyer
I installed nvm-windows in order to get multiple versions of node to work. After installation I got the error that most folks complained about which is that it was unable to find the file settings.txt. There are two things required to get nvm-win to work and the installer only does the first of these two. So after installation just check that points 1 and 2 are covered and you should be good. There is no need to uninstall prior versions of node as far as i can tell.
我安装了 nvm-windows 以便让多个版本的节点工作。安装后,我收到了大多数人抱怨的错误,即无法找到文件 settings.txt。要让 nvm-win 工作需要两件事,安装程序只做这两件事中的第一件事。因此,安装后只需检查第 1 点和第 2 点是否已覆盖,您应该就可以了。据我所知,没有必要卸载以前版本的节点。
- update the system path variable to the directory where you installed nvm and where the nvm.exe is located. ex. c:\nvm
- add a new variable NVM_HOME to the system variables.
- open a new command window after verifying 1 and 2.
- 将系统路径变量更新到您安装 nvm 的目录和 nvm.exe 所在的目录。前任。c:\nvm
- 将新变量 NVM_HOME 添加到系统变量中。
- 验证1和2后打开一个新的命令窗口。
Problem 2 switching between versions
问题二版本切换
Switching between versions gives a success message but it will not actually work properly unless you manually update the windows system path variable to point to the location that you installed your target version in, for example C:\Users\adamm>nvm list
在版本之间切换会显示成功消息,但除非您手动更新 Windows 系统路径变量以指向安装目标版本的位置,否则它实际上不会正常工作,例如 C:\Users\adamm>nvm list
10.15.1
* 6.4.0 (Currently using 64-bit executable) So it appears to work but if you type node -v it will show whichever version is currently in your path variable until you edit the path variable to use 6.4.0
* 6.4.0(当前使用 64 位可执行文件)因此它似乎可以工作,但是如果您键入 node -v,它将显示当前在您的路径变量中的版本,直到您编辑路径变量以使用 6.4.0
回答by Charles Dominic
Why isn't node version changing with nvm for windows even when nvm on ?
为什么即使在 nvm on 时节点版本也不随 nvm for windows 变化?
when nodejs is already installed, the enviroment variable NVM_SYMLINKwhich created when nvm for windows is installed will point to C:\Program Files\nodejs(which is default)
当已经安装了NVM_SYMLINKnodejs 时,安装 nvm for windows 时创建的环境变量将指向C:\Program Files\nodejs(这是默认值)
what is the expected behavior ?
什么是预期的行为?
when we run nvm onand then nvm use x.x.x, we should able to switch to the desired node version without any hassle.
当我们运行nvm on然后nvm use x.x.x,我们应该能够毫不费力地切换到所需的节点版本。
how to fix ?
怎么修 ?
- uninstall the nodejs using uninstall/remove programs from control panel and delete
C:\Program Files\nodejsif exists - check (once) if
NVM_SYMLINKin environment variables is changing automatically when runningnvm use x.x.x - if not changing automatically then uninstall and reinstall nvm for windows (remove any other node remains)
- 使用控制面板中的卸载/删除程序卸载 nodejs 并删除(
C:\Program Files\nodejs如果存在) - 检查(一次)
NVM_SYMLINK环境变量是否在运行时自动更改nvm use x.x.x - 如果没有自动更改,则卸载并重新安装 nvm for windows(删除任何其他节点仍然存在)
Note: I am able to switch to the desired versions of node by changing the user environment variable NVM_SYMLINKto C:\Users\Charlie\AppData\Roaming\nvm\vx.x.xwithout uninstalling the node.
注意:我可以通过将用户环境变量更改NVM_SYMLINK为C:\Users\Charlie\AppData\Roaming\nvm\vx.x.x无需卸载节点来切换到所需的节点版本。

