连接ETIMEDOUT npm grunt模块

时间:2014-08-05 14:49:35

标签: node.js gruntjs npm

我无法安装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 个答案:

答案 0 :(得分: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/

问候。

答案 1 :(得分:0)

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

  1. SETX HTTP_PROXY http://proxy-server-address:8080 (它应返回SUCCESS。您也可以在系统属性......高级...环境变量中执行此操作)
  2. 关闭命令提示符窗口并再次打开。 (这可确保您的新环境变量将在您的会话中使用。)
  3. 现在运行安装命令:npm install -g grunt-cli