简体   繁体   English

无法安装node_modules

[英]not able to install node_modules

I am trying to install node_module but getting following error: 我正在尝试安装node_module但收到以下错误:

For example:npm install grunt-preprocess 例如: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

The registry URL is pointing to https , you could try changing it by 注册表URL指向https ,您可以尝试更改它

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

and then try installing the module. 然后尝试安装模块。 It may be possible that you are behind a proxy that is blocking secure ( https ) connections 您可能在阻止安全( https )连接的代理后面

If it doesn't work then may be you could manually try to download the current version of the module you are trying to install from the here 如果它不起作用,那么您可以手动尝试从此处下载您尝试安装的模块的当前版本

And run the command npm install grunt-preprocess-2.3.0.tgz 并运行命令npm install grunt-preprocess-2.3.0.tgz

I also had ETIMEDOUT errors and was able to resolve the issue by disabling my router's firewall, rebooting it, and most importantly, configuring the number of simultaneous connections with the following npm command: 我也有ETIMEDOUT错误,并且能够通过禁用路由器的防火墙,重新启动它来解决问题,最重要的是,使用以下npm命令配置同时连接的数量:

npm set maxsockets 3

This sets a max number of connections of 3, instead of the default 50. The CLI has been allowing this option since npm@3.8.0. 这将最大连接数设置为3,而不是默认值50.自npm@3.8.0起,CLI已允许此选项。 See this link for further reference. 有关详细参考,请参阅此链接

I'm getting the exact same thing. 我得到完全相同的东西。 Either the module exists but the actual download repository is down or there is a problem with npm at the moment. 模块存在,但实际的下载存储库已关闭,或者此刻npm存在问题。 Try again in a few days or report it to the github link. 几天后再试一次或将其报告给github链接。

Edit: 编辑:

The error you are getting is a timeout from their server or your connection. 您收到的错误是服务器或连接超时。 It could be because you are behind a firewall/proxy that is stopping your connections. 可能是因为您在阻止连接的防火墙/代理后面。

Try the answer by @ Canmah. 尝试@ Canmah的答案。 If it does not help try to check your proxy configuration. 如果它没有帮助尝试检查您的代理配置。

If there is a proxy, update the npm registry as mentioned below and then try installing the node module. 如果有代理,请按照下面的说明更新npm注册表,然后尝试安装节点模块。

@ the command prompt update the 
npm config set proxy <proxyserver>:<port>

This might be a problem with module bin-wrapper which does not respect proxies and that is why you see the ETIMEDOUT error when trying to download. 这可能是模块bin-wrapper的一个问题,它不尊重代理,这就是你在尝试下载时看到ETIMEDOUT错误的原因。

To solve the issue you can set the environment variable HTTP_PROXY and/ or HTTPS_PROXY. 要解决此问题,您可以设置环境变量HTTP_PROXY和/或HTTPS_PROXY。
Works under Windows/ Linux. 适用于Windows / Linux。

The solved bin-wrapper issue. 解决了bin-wrapper问题。
Commit with fix. 提交修复。

The code piece in the fix: 修复中的代码片段:

var proxyServer = process.env.HTTPS_PROXY || 
                  process.env.https_proxy ||
                  process.env.HTTP_PROXY ||
                  process.env.http_proxy;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM