electron-builder 在打包时会检测cache中是否有electron 包,如果没有的话会从github上拉去,在国内网络环境中拉取的过程大概率会失败,所以你可以自己去下载一个包放到cache目录里
各个平台的目录地址
Linux: $XDG_CACHE_HOME or ~/.cache/electron/
MacOS: ~/Library/Caches/electron/
Windows: %LOCALAPPDATA%/electron/Cache or ~/AppData/Local/electron/Cache/
参考:https://github.com/electron/get#how-it-works
例如在macos平台打包electron应用,执行 electron-builder --mac --x64
? clipboard git:(master) ? npm run dist
> [email protected] dist /Users/xx/workspace/electron/clipboard
> electron-builder --mac --x64
? electron-builder version=22.3.2 os=18.7.0
? loaded configuration file=package.json ("build" field)
? writing effective config file=dist/builder-effective-config.yaml
? packaging platform=darwin arch=x64 electron=8.0.0 appOutDir=dist/mac
? downloading url=https://github.com/electron/electron/releases/download/v8.0.0/electron-v8.0.0-darwin-x64.zip size=66 MB parts=8
可以单独下载这个包 https://github.com/electron/electron/releases/download/v8.0.0/electron-v8.0.0-darwin-x64.zip, 放到~/Library/Caches/electron/ 目录下
然后可以打包完成
原文地址:https://www.cnblogs.com/xiaoniuzai/p/12356208.html
时间: 2024-10-14 12:11:50