[英]Stuck on an older version after installed a new one
node --version
v4.5.0
npm --version
2.15.9
node-gyp --version
v3.4.0
which node
/home/admin/.nvm/versions/node/v4.5.0/bin/node
For some reason, after running sudo npm install -g node-gyp
- node-gyp installs with node v0.10.25:出于某种原因,在运行sudo npm install -g node-gyp
gyp - node-gyp 安装节点 v0.10.25 后:
npm WARN engine cryptiles@2.0.5: wanted: {"node":">=0.10.40"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm WARN engine boom@2.10.1: wanted: {"node":">=0.10.40"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm WARN engine hoek@2.16.3: wanted: {"node":">=0.10.40"} (current: {"node":"v0.10.25","npm":"1.3.10"})
I've accessed /home/admin/.nvm/versions/node/
and found those folders: v4.4.4, v4.4.7, v4.5.0
.我访问了/home/admin/.nvm/versions/node/
并找到了这些文件夹: v4.4.4, v4.4.7, v4.5.0
。
Can someone trigger the issue ?有人可以触发这个问题吗? Where is that v0.10.25 version and how do I get rid of it ? v0.10.25 版本在哪里,我该如何摆脱它?
The issue is that you, as a normal user , are using nvm
, Node Version Manager, which allows you to install different (newer/older) versions of Node independently of the system-installed version of Node (which, in your case, is 0.10.25).问题是,作为普通用户,您使用的是nvm
、Node 版本管理器,它允许您独立于系统安装的 Node 版本(在您的情况下是0.10.25)。
When you install node-gyp
using sudo
, you're "switching" to a different user (root), for which the nvm setup doesn't apply.当您使用sudo
安装node-gyp
,您正在“切换”到不同的用户(root),nvm 设置不适用于该用户。 Hence, the system-installed version of Node will be used, triggering the error you're getting.因此,将使用系统安装的 Node 版本,从而触发您遇到的错误。
You have a few solutions:你有几个解决方案:
sudo
when installing node-gyp
.安装node-gyp
时不要使用sudo
。 Because you're using nvm
, you already have all the permissions required to install it as a normal user.因为您使用的是nvm
,所以您已经拥有以普通用户身份安装它所需的所有权限。You might have to clean/remove the other versions of Node.您可能需要清理/删除其他版本的 Node.js。 Perhaps the easiest is to remove everything and then install afresh.也许最简单的方法是删除所有内容,然后重新安装。 There's a script ( install.sh
) for this on npmjs.org site .在npmjs.org 站点上有一个脚本( install.sh
)。 Simply run this on your terminal and then it should remove any old installations and install the latest version.只需在您的终端上运行它,然后它应该删除所有旧安装并安装最新版本。
Give it a try and let me know if this helps.试一试,让我知道这是否有帮助。 It seems to have worked for closely related problem here .它似乎在这里解决了密切相关的问题。
I had the same problem.我有同样的问题。 i found that i had a node.exe file with old version, and in the PATH (environment variables) i had a link to this old node.exe folder.我发现我有一个旧版本的 node.exe 文件,在 PATH(环境变量)中,我有一个指向这个旧 node.exe 文件夹的链接。 once removing it from the path (and restarting cmd) the problem was fixed一旦从路径中删除它(并重新启动 cmd),问题就解决了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.