简体   繁体   English

npm错误无效semver

[英]npm error invalid semver

Just installed Node.js v.0.10.20 from source. 刚从源代码安装了Node.js v.0.10.20。 Target box Ubuntu 12.04.3 LTS. 目标框Ubuntu 12.04.3 LTS。 Node is installing ok without errors. 节点安装正常没有错误。 After all it seems : 毕竟它似乎:

node -v
v0.10.20

npm -v
1.3.11

But just listing my -g modules, I get some odd messages I can't figure out : 但只是列出我的-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

and at a bottom of -g listing, I see more messages : 在-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

Also I can see under npm@1.3.11 -module the row: 我也可以在npm@1.3.11下看到-module行:

│ ├── semver@2.1.0 invalid

This same happens in previous node version (0.10.18) if I remember that right. 如果我没记错的话,在前一个节点版本(0.10.18)中也会发生这种情况。

Annoying message that I can't solve. 恼人的消息,我无法解决。 I'm sure I haven't installed semver-module manually and quite sure that none of my installed node-modules is using semver. 我确定我没有手动安装semver-module,并确保我安装的任何节点模块都没有使用semver。


Edit: thanks to Nirk, re-installing npm will solve this. 编辑:感谢Nirk,重新安装npm将解决这个问题。 To be sure, I gave sudo su - and re-installed as root. 可以肯定的是,我给了sudo su -并以root身份重新安装。 Maybe just sudo :ing works as well. 也许只是sudo :ing也可以。

Here is what I did : 这是我做的:

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:~#

Note that URL has moved to https://npmjs.org/install.sh 请注意,URL已移至https://npmjs.org/install.sh

You have an older version of normalize-package-data (the current version depends on semver version 2: https://github.com/meryn/normalize-package-data/blob/master/package.json#L15 ) 你有一个旧版本的normalize-package-data(当前版本取决于semver版本2: https//github.com/meryn/normalize-package-data/blob/master/package.json#L15

To forcefully reinstall npm without using npm, try using the shell script 要在不使用npm的情况下强制重新安装npm,请尝试使用shell脚本

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

Try un/reinstalling it if you are sure you aren't using it. 如果您确定不使用它,请尝试取消/重新安装。 That should get rid of the error message. 那应该摆脱错误信息。

npm un semver -g and then npm install semver -g npm un semver -g然后npm install semver -g

Edit: it seems that one of your modules needs semver@1.x so try sudo npm install semver@1.1.4 -g 编辑:似乎你的一个模块需要semver@1.x所以试试sudo npm install semver@1.1.4 -g

Note the URL has moved to: https://www.npmjs. 请注意,URL已移至: https://www.npmjs。 com /install.sh (as of Apr 2015) com /install.sh (截至2015年4月)

This should work: 这应该工作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM