使用npm安装grunt-browser-sync时出错

时间:2015-10-16 07:04:55

标签: javascript node.js gruntjs npm browser-sync

我正在尝试通过 npm (版本3.3.8)安装 grunt-browser-sync 插件:

npm install grunt-browser-sync --save-dev

首先我的终端在加载xmlhttprequest时挂起: enter image description here

然后等了一会儿,我得到了这个错误: enter image description here

如果我在浏览器中导航到网址https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz,则可以正常工作..

我正在使用Windows 7 Enterprise。
npm版本3.3.8。
我在代理服务器后面工作,但设置正确,因为我可以安装其他npm模块

我已经尝试过:

  • 使用不同版本的npm(3.3.1,3.3.5,3.3.6,3.3.7)
  • npm cache clean

1 个答案:

答案 0 :(得分:0)

问题似乎是npm在代理上使用HTTPS并不是那么好。将注册表URL从HTTPS更改为HTTP是一种解决方法:

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

但是你的问题似乎并没有结束,因为它没有从http://registry.npmjs.org获得依赖,但来自:https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz

由于你是在代理之后,使用npm有时候会非常痛苦。因此,您必须配置npm才能使用您的网络代理。这是一个例子:

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080