国内镜像安装Electron
linux
sh
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
npm install --registry=https://registry.npmmirror.com -g electron
windows
sh
set ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
npm install --registry=https://registry.npmmirror.com -g electron
electron-builder打包出错
sh
✓ built in 21ms 11:07:13
• electron-builder version=24.13.3 os=10.0.26100
• loaded configuration file=D:\mycode\image-compress\electron-builder.json5
• writing effective config file=release\2.0.0\builder-effective-config.yaml
• packaging platform=win32 arch=x64 electron=29.4.6 appOutDir=release\2.0.0\win-unpacked
⨯ Get "https://github.com/electron/electron/releases/download/v29.4.6/electron-v29.4.6-win32-x64.zip": proxyconnect tcp: dial tcp 127.0.0.1:9876: connectex: No connection could be made because the target machine actively refused it.
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
github.com/develar/app-builder/pkg/download.(*Downloader).Download
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:112
github.com/develar/app-builder/pkg/electron.(*ElectronDownloader).doDownload
/Volumes/data/Documents/app-builder/pkg/electron/electronDownloader.go:192
github.com/develar/app-builder/pkg/electron.(*ElectronDownloader).Download
/Volumes/data/Documents/app-builder/pkg/electron/electronDownloader.go:177
github.com/develar/app-builder/pkg/electron.downloadElectron.func1.1
/Volumes/data/Documents/app-builder/pkg/electron/electronDownloader.go:73
github.com/develar/app-builder/pkg/util.MapAsyncConcurrency.func2
/Volumes/data/Documents/app-builder/pkg/util/async.go:68
runtime.goexit
/usr/local/Cellar/go/1.17/libexec/src/runtime/asm_amd64.s:1581
⨯ D:\mycode\image-compress\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1 failedTask=build stackTrace=Error: D:\mycode\image-compress\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
at ChildProcess.<anonymous> (D:\mycode\image-compress\node_modules\builder-util\src\util.ts:252:14)
at Object.onceWrapper (node:events:632:26)
at ChildProcess.emit (node:events:517:28)
at ChildProcess.cp.emit (D:\mycode\image-compress\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (node:internal/child_process:1098:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:303:5)
查看日志可以看到,是下载这个文件失败造成
https://github.com/electron/electron/releases/download/v29.4.6/electron-v29.4.6-win32-x64.zip
直接手动下载文件,复制到以下文件夹即可
C:\Users\Administrator\AppData\Local\electron\Cache