electron-builder 在打包时会检测cache中是否有electron 包,如果没有的话会从github上拉去,在国内网络环境中拉取的过程大概率会失败,所以你可以自己去下载一个包放到cache目录里
我的是Mac电脑,目录在: ~/Library/Caches/electron/
可以在这里找到自己电脑的cache目录在哪里:https://github.com/electron/get#how-it-works

例如在macos平台打包electron应用,执行 electron-builder --mac --x64

Building app with electron-builder:
  • electron-builder  version=22.11.7 os=19.6.0
  • description is missed in the package.json  appPackageFile=/Volumes/HDD/workshop/git/gitee.com/hess/hess-return/dist_electron/bundled/package.json
  • author is missed in the package.json  appPackageFile=/Volumes/HDD/workshop/git/gitee.com/hess/hess-return/dist_electron/bundled/package.json
  • writing effective config  file=dist_electron/builder-effective-config.yaml
  • packaging       platform=darwin arch=x64 electron=13.1.7 appOutDir=dist_electron/mac
  • downloading     url=https://github.com/electron/electron/releases/download/v13.1.7/electron-v13.1.7-darwin-x64.zip size=79 MB parts=8

可以单独下载这个包 https://github.com/electron/electron/releases/download/v13.1.7/electron-v13.1.7-darwin-x64.zip, 放到~/Library/Caches/electron/ 目录下

然后可以打包完成