无法安装node_modules
我正在尝试安装node_module但出现以下错误:
例如:npm install grunt-preprocess
D:\grunt_pre>npm install grunt-preprocess npm http GET https://registry.npmjs.org/grunt-preprocess npm http GET https://registry.npmjs.org/grunt-preprocess npm http GET https://registry.npmjs.org/grunt-preprocess npm ERR! Error: connect ETIMEDOUT npm ERR! at errnoException (net.js:901:11) npm ERR! at Object.afterConnect [as oncomplete] (net.js:892:19) npm ERR! If you need help, you may report this log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! <npm-@googlegroups.com> npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt-preprocess" npm ERR! cwd D:\grunt_pre npm ERR! node -v v0.10.15 npm ERR! npm -v 1.3.5 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! D:\grunt_pre\npm-debug.log npm ERR! not ok code 0
registryURL指向https
,你可以尝试改变它
npm config set registry="http://registry.npmjs.org/"
然后尝试安装模块。 您可能位于阻止安全( https
)连接的代理之后
如果它不起作用,那么可能是你可以手动尝试从这里下载你正在尝试安装的模块的当前版本
并运行命令npm install grunt-preprocess-2.3.0.tgz
我也有ETIMEDOUT
错误,并能够通过禁用我的路由器的防火墙,重新启动它,并且最重要的是通过以下npm命令configuration同时连接的数量来解决问题:
npm set maxsockets 3
这将最大连接数设置为3,而不是默认的50.自npm@3.8.0以来,CLI一直允许使用此选项。 看到这个链接进一步参考。
我得到完全相同的东西。 或者模块存在,但实际的下载库已经closures,或者npm目前有问题。 几天后再试一次或者将它报告给github链接。
编辑:
你得到的错误是从他们的服务器或你的连接超时。 这可能是因为你正在阻止你的连接的防火墙/代理之后。
试试@Canmah的答案。 如果它不帮你尝试检查你的代理configuration。
如果有代理,请按照下面的提示更新npmregistry,然后尝试安装节点模块。
@ the command prompt update the npm config set proxy <proxyserver>:<port>
这可能是模块bin-wrapper不尊重代理的问题,这就是为什么你看到ETIMEDOUT错误,当试图下载。
要解决这个问题,你可以设置环境variablesHTTP_PROXY和/或HTTPS_PROXY。
在Windows / Linux下工作。
解决了bin-wrapper问题。
提交并修复。
修复中的代码片段:
var proxyServer = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;