【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/
相关推荐
笃行3504 小时前
集中式与分布式,KingbaseES 的四种形态共用一套内核
前端
陈随易5 小时前
Vue 编译器换掉 source map,快了三四成
前端·后端·程序员
ZhengEnCi6 小时前
12 种高级 UI 交互效果及对应 AI 提示词:从按压回弹到底部抽屉的物理感教学
前端·css·交互设计
IT_陈寒9 小时前
Redis大key删除为什么会导致服务卡顿?我的线上事故复盘
前端·人工智能·后端
系统集成-鹰翔9 小时前
ERP图片改名后仍命中识别缓存:缓存键、十分钟到期与调用计数
javascript·经验分享·后端
用户27050777252410 小时前
MCP 最小 Server 实测:3 个 JSON-RPC 报错与修法
前端
用户4993350250710 小时前
一人VIP账号多人共用:Web 代理里的会话共享怎么实现
前端
用户老李10 小时前
无线电自学教程 05:第一台收音机——从矿石机到 SDR
前端
IPIPD10 小时前
Node.js请求遇到503怎么重试?先解析Retry-After,再做有上限退避
前端
葡萄城技术团队10 小时前
dsh-spreadjs-editor 的集成链路:把 SpreadJS Designer 嵌进 Agent 工作台
前端