Node.js npm错误无效semver

Node.js npm错误无效semver,node.js,npm,Node.js,Npm,刚刚从源代码处安装了Node.jsv.0.10.20。目标框Ubuntu 12.04.3 LTS。 节点正在安装,没有错误。毕竟,似乎: node -v v0.10.20 npm -v 1.3.11 但仅仅列出我的-g模块,我就得到了一些奇怪的信息,我无法理解: esa@fingolfin:~$ npm list -g npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/normalize-packag

刚刚从源代码处安装了Node.jsv.0.10.20。目标框Ubuntu 12.04.3 LTS。 节点正在安装,没有错误。毕竟,似乎:

node -v
v0.10.20

npm -v
1.3.11
但仅仅列出我的-g模块,我就得到了一些奇怪的信息,我无法理解:

esa@fingolfin:~$ npm list -g
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/normalize-package-data requires semver@'1.x' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/semver,
npm WARN unmet dependency which is version 2.1.0
在-g列表的底部,我看到了更多的消息:

npm ERR! invalid: semver@2.1.0 /usr/local/lib/node_modules/npm/node_modules/semver
npm ERR! extraneous: normalize-package-data@0.1.7 /usr/local/lib/node_modules/npm/node_modules/normalize-package-data
npm ERR! not ok code 0
我也能看到下面npm@1.3.11-模块行:

│ ├── semver@2.1.0 invalid
如果我没记错的话,在以前的节点版本(0.10.18)中也会发生同样的情况

我无法解决的恼人消息。我确信我没有手动安装semver模块,而且我确信我安装的所有节点模块都没有使用semver


编辑:多亏了Nirk,重新安装npm将解决这个问题。可以肯定的是,我给了sudo su-,并重新安装为root。也许只是苏多(sudo):ing也能起作用

以下是我所做的:

sudo su -


root@fingolfin:~# curl https://npmjs.org/install.sh | sh

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7882  100  7882    0     0  13118      0 --:--:-- --:--:-- --:--:-- 23669
tar=/bin/tar
version:
tar (GNU tar) 1.26

Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-1.3.11.tgz
0.10.20
1.3.11
cleanup prefix=/usr/local

All clean!
unbuild npm@1.3.11
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@1.3.11 /usr/local/lib/node_modules/npm
It worked
root@fingolfin:~#
sudo su-
root@fingolfin:~#卷曲https://npmjs.org/install.sh |嘘
%总接收百分比%x平均速度时间电流
数据加载上载总左速度
100  7882  100  7882    0     0  13118      0 --:--:-- --:--:-- --:--:-- 23669
tar=/bin/tar
版本:
焦油(GNU焦油)1.26
版权所有(C)2011免费软件基金会。
许可证GPLv3+:GNU GPL版本3或更高版本。
这是自由软件:您可以自由更改和重新发布它。
在法律允许的范围内,不存在任何担保。
由约翰·吉尔摩和杰伊·芬拉森撰写。
安装npm@latest
获取:http://registry.npmjs.org/npm/-/npm-1.3.11.tgz
0.10.20
1.3.11
清除前缀=/usr/local
都干净了!
拆建npm@1.3.11
/usr/local/bin/npm->/usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@1.3.11/usr/local/lib/node\u modules/npm
它起作用了
root@fingolfin:~#

请注意,URL已移动到https://npmjs.org/install.sh

如果确定没有使用,请尝试取消/重新安装。这将消除错误消息

npm卸载semver-g
然后
npm安装semver-g


编辑:似乎您的一个模块需要semver@1.x因此,请尝试
sudo npm安装semver@1.1.4-g

您有一个旧版本的规范化软件包数据(当前版本取决于semver版本2:)

要在不使用npm的情况下强制重新安装npm,请尝试使用shell脚本

curl https://npmjs.org/install.sh | sh

请注意,URL已移动到:https://www.npmjs.com/install.sh(截至2015年4月)

这应该起作用:

curl https://npmjs.com/install.sh | sh

是的,它起作用了!没有“npm列表-g”是干净的。也许这不会造成任何伤害,但最好确定。谢谢如果其他人需要,我将用详细的解决方案编辑我的原始问题。