Electron RequestError: connect ETIMEDOUT 20.205.243.166:443

问题描述

下载 electron 时,卡在了下载超时,换 github.com ip 无效、用梯子无效,直到官网这里找到了原因:

Mirror

You can use environment variables to override the base URL, the path at which to look for Electron binaries, and the binary filename. The URL used by @electron/get is composed as follows:

url = ELECTRON_MIRROR + ELECTRON_CUSTOM_DIR + '/' + ELECTRON_CUSTOM_FILENAME

For instance, to use the China CDN mirror:

ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/"

解决办法

1、找国内镜像,比如npmmirror 中国镜像站:

electron 镜像: https://npmmirror.com/mirrors/electron/

2、设置:

# yarn
yarn config set electron_mirror https://npmmirror.com/mirrors/electron/

# npm
npm config set ELECTRON_MIRROR https://npmmirror.com/mirrors/electron/

或者配置 npmrc

在项目根目录新建 .npmrc,内容:

electron_mirror=https://npmmirror.com/mirrors/electron/

你可能感兴趣的:(日常报错归纳,前端,工具,electron,npm,node.js)