问题描述

安装electron项目的时候,在下载包的时候报错
错误描述主要是

错误1:socket hang up

error E:\theia\node_modules\electron: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: E:\theia\node_modules\electron
Output:
RequestError: socket hang up
    at ClientRequest.<anonymous> (E:\theia\node_modules\got\source\request-as-event-emitter.js:178:14)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:326:22)
    at ClientRequest.origin.emit (E:\theia\node_modules\@szmarczak\http-timer\source\index.js:37:11)
    at TLSSocket.socketOnEnd (_http_client.js:458:9)

错误2: Client network socket disconnected before secure TLS connection was established

error E:\theia\node_modules\electron: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: E:\theia\node_modules\electron
Output:
RequestError: Client network socket disconnected before secure TLS connection was established
    at ClientRequest.<anonymous> (E:\theia\node_modules\got\source\request-as-event-emitter.js:178:14)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:326:22)
    at ClientRequest.origin.emit (E:\theia\node_modules\@szmarczak\http-timer\source\index.js:37:11)
    at TLSSocket.socketErrorListener (_http_client.js:427:9)
    at TLSSocket.emit (events.js:314:20)

问题分析

看错误描述应该是网络异常,因为我的是在公司起的项目,有可能做了代理屏蔽,所以大概率是镜像问题,但是我自己重新试试挂载淘宝的NPM的镜像,同样异常。经过一番查找发现了有人也出现类似的问题,这里地址:解决安装electron卡在node install.js 不动问题

主要是因为 electron-download里模块的安装异常,可以通过设置electron代理解决
在这里插入图片描述

设置

终端执行 npm config set electron_mirror https://npm.taobao.org/mirrors/electron/就能正常运行了

Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐