刚刚从源代码安装了 Node.js v.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: [email protected] /cdn-cgi/l/email-protection /usr/local/lib/node_modules/npm/node_modules/semver
npm ERR! extraneous: [email protected] /cdn-cgi/l/email-protection /usr/local/lib/node_modules/npm/node_modules/normalize-package-data
npm ERR! not ok code 0
我也可以看到下面[电子邮件受保护] /cdn-cgi/l/email-protection- 模块行:
│ ├── [email protected] /cdn-cgi/l/email-protection invalid
如果我没记错的话,在以前的节点版本(0.10.18)中也会发生同样的情况。
我无法解决的烦人消息。我确定我没有手动安装 semver-module,并且非常确定我安装的节点模块都没有使用 semver。
编辑:感谢 Nirk,重新安装 npm 将解决这个问题。可以肯定的是,我给了须藤苏-并以 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 [email protected] /cdn-cgi/l/email-protection
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
[email protected] /cdn-cgi/l/email-protection /usr/local/lib/node_modules/npm
It worked
root@fingolfin:~#
请注意,网址已移至https://npmjs.org/install.sh