【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/
相关推荐
小羊没烦恼!1 分钟前
在.net中读写config文件的各种方法
java·大数据·运维·服务器·前端·数据库·oracle
@PHARAOH22 分钟前
WHAT - Vite 8(Rolldown 底层构建引擎升级)
前端·架构
阿Q的AI笔记26 分钟前
从ReAct到GRPO、从OpenHands到SWE-agent:Agent完整知识体系全拆解
前端·react.js·前端框架
计算机魔术师31 分钟前
从六个月路线图到JIT规划:代码评审不只是审代码
前端
迅猛龙办公室36 分钟前
Python实现PM空气质量提醒
服务器·前端·python
ydjs678899-bot1 小时前
您的Next.js中间件匹配器配置可能会跳过您认为它保护的路由
开发语言·javascript·中间件
Chengbei111 小时前
JsOwl|AI 赋能 JS 敏感信息扫描器,AST + 正则、source‑map 源码还原、登录态爬虫输出交互式 HTML 报告
开发语言·javascript·网络·人工智能·爬虫·网络安全·自动化
鬼手点金2 小时前
模型即 Agent:当模型本身成为产品
开发语言·前端·人工智能·python·机器学习
kiracrimson2 小时前
npm 入门:包管理器、依赖与 npx
前端·npm·node.js