【问题标题】:Unable to install electron from npm无法从 npm 安装电子
【发布时间】:2018-06-01 18:40:59
【问题描述】:

我正在尝试在我的 ubuntu 16.04 上安装电子,我已经有一个工作的 nodejs 和 npm。但突然我无法按类型安装模块: sudo npm install electron

以下是收到的回复:

npm WARN registry Unexpected warning for https://registry.npmjs.org/: 
Miscellaneous Warning EAI_AGAIN: request to 
https://registry.npmjs.org/electron failed, reason: getaddrinfo 
EAI_AGAIN registry.npmjs.org:443
npm WARN registry Using stale package data from 
https://registry.npmjs.org/ due to a request error during 
revalidation.

> electron@1.7.10 postinstall 
/home/arthur/Documents/Programming/Electron/node_modules/electron
> node install.js



 `/home/arthur/Documents/Programming/Electron/node_modules/electron/
install.js:48

抛出错误 ^

Error: read ECONNRESET
at _errnoException (util.js:1024:11)
at TLSWrap.onread (net.js:615:25)
npm WARN y@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@1.7.10 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@1.7.10 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/arthur/.npm/_logs/2017-12-19T10_25_52_312Z-
debug.log

【问题讨论】:

  • 您是否已经成功使用npm install 安装软件包或者这是第一次尝试?
  • 是的,最初我能够做到,直到现在。
  • 你使用的 npm 版本是什么?
  • 我正在使用 npm 版本 8.9.1。无论如何,从我的配置中删除我的代理和 http-proxy 是有效的。它现在工作正常
  • 感谢您的努力。

标签: node.js electron npm-install


【解决方案1】:

我支持公司代理并且遇到了类似的问题。上述选项均无帮助。最后,我按照下面的说明手动重建了电子缓存,这样它就不必打网络下载二进制文件:

https://www.electronjs.org/docs/v14-x-y/tutorial/installation#custom-mirrors-and-caches

基本上我使用个人笔记本电脑(即不在代理后面)在一些测试应用程序上安装最新的电子,然后将 %LOCALAPPDATA%\electron\Cache 文件夹从我的个人电脑复制到公司笔记本电脑。一切正常。

【讨论】:

    【解决方案2】:

    执行以下任一操作。它对我有用。

    1. 更改互联网连接。
    2. 删除所有电子文件,然后安装 npm insatll electron。
    3. 尝试安装旧版电子。

    这个错误是因为它无法下载“electron-v11.2.1-win32-x64.zip”文件。所以更改 Internet 连接对我有用。

    【讨论】:

      【解决方案3】:

      我尝试了一切,但似乎我使用的是允许我安装电子的 CENTOS。我得到了FlashJonas 的帮助:并尝试再次安装 electron 并按预期安装。

      sudo npm install electron -g --verbose --unsafe-perm=true
      

      【讨论】:

        【解决方案4】:

        问题与代理配置有关。基于这个answer,你可以尝试以下方法。

        首先,如果存在您的初始配置,请尝试删除:

        npm config rm proxy
        npm config rm https-proxy
        

        如果需要,可以选择尝试设置您的代理配置

        npm config set proxy proxy-url
        npm config set https-proxy proxy-url
        

        【讨论】:

        • 即使没有设置代理和 https-proxy url,上述答案也有效
        • @ArthurKalikiti 我编辑了答案,以便尽可能保持一般性
        【解决方案5】:

        删除代理和 https-proxy 对我有用,以防万一有其他人有类似情况。 只需在终端中输入以下内容:

        npm config rm proxy
        npm config rm https-proxy
        

        【讨论】:

          猜你喜欢
          • 2018-05-20
          • 1970-01-01
          • 2019-01-18
          • 2020-06-25
          • 2014-09-19
          • 1970-01-01
          • 2015-12-07
          • 1970-01-01
          相关资源
          最近更新 更多