12.04 中的 grunt 安装错误

Rag*_*hav 2 12.04 grunt

我尝试使用 npm 安装 grunt,但出错了,但没有详细说明推理。在这里重现日志。

npm -v
1.1.4

sudo npm install -g grunt-cli
npm http GET https://registry.npmjs.org/grunt-cli

npm ERR! Error: failed to fetch from registry: grunt-cli
npm ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR!     at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
npm ERR!     at ClientRequest.g (events.js:156:14)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1256:7)
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /home/raghav/npm-debug.log npm
npm ERR! 
npm ERR! System Linux 3.5.0-47-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "grunt-cli"
npm ERR! cwd /home/raghav
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: grunt-cli
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/raghav/npm-debug.log
npm not ok
Run Code Online (Sandbox Code Playgroud)

试图确认我是否真的可以访问服务器,这里是 -

ping registry.npmjs.org
PING a.sni.fastly.net (103.245.222.162) 56(84) bytes of data.
64 bytes from 103.245.222.162: icmp_req=1 ttl=50 time=243 ms
Run Code Online (Sandbox Code Playgroud)

qri*_*ris 5

正如@geon 在StackOverflow上指出的那样:

我使用 apt-get 安装节点。Npm 未包含在该软件包中,因此必须单独安装。我认为这会起作用,但显然 Ubuntu 发行版中的 npm 版本已经过时了。

节点维基有这个指令:

获取最新版本的 Node 或安装在较旧的 Ubuntu 和其他基于 apt 的发行版上可能需要一些额外的步骤。安装示例:

sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Run Code Online (Sandbox Code Playgroud)

在那之后,npm 已经包含在内并且完美运行。