连接超时 npm grunt 模块

3

我无法安装grunt模块。

C:\Users\maah4>npm install -g grunt-cli
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/grunt-cli
npm ERR! network connect ETIMEDOUT
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settin
gs.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "grunt-cli"
npm ERR! cwd C:\Users\maah4
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\maah4\npm-debug.log
npm ERR! not ok code 0

我还尝试了以下配置。但它没有起作用。

npm config set registry http://registry.npmjs.org/

我有一些代理,但我可以通过浏览器访问。

请告诉我如何解决这个问题。

2个回答

5

也许你在家或办公室使用的防火墙屏蔽了npm。

如果你通过npm设置代理,就可以解决这个问题。

npm config set proxy http://proxy-server-address:8080
npm config set https-proxy http://proxy-server-address:8080

也许这个链接能对你有所帮助: http://blog.michaelfasani.com/tag/npm/ 祝好。

0

尝试在环境变量中设置代理值。在命令提示符中运行以下命令:

  1. SETX HTTP_PROXY http://proxy-server-address:8080 (应该返回成功消息。也可以在系统属性...高级...环境变量中进行设置)
  2. 关闭命令提示符窗口,然后重新打开。(这样可以确保新的环境变量在会话中生效
  3. 现在运行安装命令:npm install -g grunt-cli

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接