【Electron】使用electron-builder打包时下载electron失败或慢的解决方案

问题描述

electron-builder打包时报错信息如下:

bash 复制代码
Building app with electron-builder:
  • electron-builder  version=22.14.5 os=10.0.19042
  • description is missed in the package.json  appPackageFile=E:\h-world\hscmweb-diagrams\dist_electron\bundled\package.json
  • author is missed in the package.json  appPackageFile=E:\h-world\hscmweb-diagrams\dist_electron\bundled\package.json
  • writing effective config  file=dist_electron\builder-effective-config.yaml
  • packaging       platform=win32 arch=x64 electron=12.2.3 appOutDir=dist_electron\win-unpacked
  • downloading     url=https://npm.taobao.org/mirrors/electron/12.2.3/electron-v12.2.3-win32-x64.zip size=83 MB parts=8
  • downloaded      url=https://npm.taobao.org/mirrors/electron/12.2.3/electron-v12.2.3-win32-x64.zip duration=2m22.249s
  • default Electron icon is used  reason=application icon is not set
  • building        target=nsis file=dist_electron\HSCM Setup 2.2.6.exe archs=x64 oneClick=true perMachine=false
  ⨯ Get "https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z": dial tcp 20.205.243.166:443: connectex: A connection attempt failed because the con
nected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
github.com/develar/app-builder/pkg/download.(*Downloader).follow.func1
        /Volumes/data/Documents/app-builder/pkg/download/downloader.go:206
github.com/develar/app-builder/pkg/download.(*Downloader).follow
        /Volumes/data/Documents/app-builder/pkg/download/downloader.go:234
github.com/develar/app-builder/pkg/download.(*Downloader).DownloadNoRetry
        /Volumes/data/Documents/app-builder/pkg/download/downloader.go:128

解决

该问题是因为electron包需要翻墙获得,需要全局代理,但是太麻烦,我们一般是修改镜像源

在项目根目录下创建.npmrc文件,并且输入以下配置:

javascript 复制代码
registry=https://registry.npm.taobao.org/
disturl=https://npm.taobao.org/mirrors/node
electron_mirror=https://npm.taobao.org/mirrors/electron/
相关推荐
长风清留扬7 分钟前
小程序毕业设计-音乐播放器+源码(可播放)下载即用
javascript·小程序·毕业设计·课程设计·毕设·音乐播放器
web1478621072320 分钟前
C# .Net Web 路由相关配置
前端·c#·.net
m0_7482478021 分钟前
Flutter Intl包使用指南:实现国际化和本地化
前端·javascript·flutter
飞的肖24 分钟前
前端使用 Element Plus架构vue3.0实现图片拖拉拽,后等比压缩,上传到Spring Boot后端
前端·spring boot·架构
青灯文案132 分钟前
前端 HTTP 请求由 Nginx 反向代理和 API 网关到后端服务的流程
前端·nginx·http
m0_7482548837 分钟前
DataX3.0+DataX-Web部署分布式可视化ETL系统
前端·分布式·etl
ZJ_.1 小时前
WPSJS:让 WPS 办公与 JavaScript 完美联动
开发语言·前端·javascript·vscode·ecmascript·wps
GIS开发特训营1 小时前
Vue零基础教程|从前端框架到GIS开发系列课程(七)响应式系统介绍
前端·vue.js·前端框架·gis开发·webgis·三维gis
Cachel wood1 小时前
python round四舍五入和decimal库精确四舍五入
java·linux·前端·数据库·vue.js·python·前端框架
学代码的小前端1 小时前
0基础学前端-----CSS DAY9
前端·css