npm 错误无效 semver [英] npm error invalid semver

查看:151
本文介绍了npm 错误无效 semver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚从源代码安装了 Node.js v.0.10.20.目标框 Ubuntu 12.04.3 LTS.节点安装正常,没有错误.毕竟看起来:

Just installed Node.js v.0.10.20 from source. Target box 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

但只是列出我的 -g 模块,我会收到一些我无法弄清楚的奇怪消息:

But just listing my -g modules, I get some odd messages I can't figure out :

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 列表的底部,我看到更多消息:

and at a bottom of -g listing, I see more messages :

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 -module 下看到该行:

Also I can see under npm@1.3.11 -module the row:

│ ├── semver@2.1.0 invalid

如果我没记错的话,在之前的节点版本 (0.10.18) 中也会发生同样的情况.

This same happens in previous node version (0.10.18) if I remember that right.

烦人的消息,我无法解决.我确定我没有手动安装 semver-module 并且很确定我安装的节点模块都没有使用 semver.

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.

感谢 Nirk,重新安装 npm 可以解决这个问题.可以肯定的是,我给了 sudo su - 并以 root 身份重新安装.也许只是 sudo:ing 也可以.

thanks to Nirk, re-installing npm will solve this. To be sure, I gave sudo su - and re-installed as root. Maybe just sudo:ing works as well.

这是我所做的:

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

请注意 URL 已移至 https://npmjs.org/install.sh

Note that URL has moved to https://npmjs.org/install.sh

推荐答案

您有较旧版本的 normalize-package-data(当前版本取决于 semver 版本 2:https://github.com/meryn/normalize-package-data/blob/master/package.json#L15 )

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 )

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

To forcefully reinstall npm without using npm, try using the shell script

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

这篇关于npm 错误无效 semver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆