【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/
相关推荐
简小瑞16 小时前
VSCode源码解密:一行代码解决内存泄漏难题
前端·设计模式·visual studio code
Asort16 小时前
JavaScript设计模式(九)——装饰器模式 (Decorator)
前端·javascript·设计模式
Man16 小时前
🔥 Vue3 动态 ref 黑科技:一招解决 v-for 中的组件引用难题!
前端·vue.js
接着奏乐接着舞。16 小时前
3D地球可视化教程 - 第3篇:地球动画与相机控制
前端·vue.js·3d·threejs
小小前端_我自坚强16 小时前
2025WebAssembly详解
前端·设计模式·前端框架
用户14125016652716 小时前
一文搞懂 Vue 3 核心原理:从响应式到编译的深度解析
前端
正在走向自律16 小时前
RSA加密从原理到实践:Java后端与Vue前端全栈案例解析
java·前端·vue.js·密钥管理·rsa加密·密钥对·aes+rsa
我是天龙_绍16 小时前
Lodash 库在前端开发中的重要地位与实用函数实现
前端
LuckySusu16 小时前
【vue篇】Vue 数组响应式揭秘:如何让 push 也能更新视图?
前端·vue.js
LuckySusu16 小时前
【vue篇】Vue 性能优化神器:keep-alive 深度解析与实战指南
前端·vue.js