【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/
相关推荐
待磨的钝刨4 分钟前
【格式化查看JSON文件】coco的json文件内容都在一行如何按照json格式查看
开发语言·javascript·json
逐·風3 小时前
unity关于自定义渲染、内存管理、性能调优、复杂物理模拟、并行计算以及插件开发
前端·unity·c#
Devil枫3 小时前
Vue 3 单元测试与E2E测试
前端·vue.js·单元测试
尚梦4 小时前
uni-app 封装刘海状态栏(适用小程序, h5, 头条小程序)
前端·小程序·uni-app
GIS程序媛—椰子5 小时前
【Vue 全家桶】6、vue-router 路由(更新中)
前端·vue.js
前端青山5 小时前
Node.js-增强 API 安全性和性能优化
开发语言·前端·javascript·性能优化·前端框架·node.js
毕业设计制作和分享5 小时前
ssm《数据库系统原理》课程平台的设计与实现+vue
前端·数据库·vue.js·oracle·mybatis
从兄6 小时前
vue 使用docx-preview 预览替换文档内的特定变量
javascript·vue.js·ecmascript
清灵xmf7 小时前
在 Vue 中实现与优化轮询技术
前端·javascript·vue·轮询
大佩梨7 小时前
VUE+Vite之环境文件配置及使用环境变量
前端