從GitLab上拉取項目代碼後,運行命令
npm run build
構建electron打包環境時,因爲某些緣由(可能被某些牆阻止等),構建環境失敗,出現超時錯誤。錯誤代碼以下:javascript
錯誤代碼段引用自:https://segmentfault.com/q/1010000022013746java
• electron-builder version=21.2.0 os=10.0.18363 • loaded configuration file=package.json ("build" field) • writing effective config file=release\builder-effective-config.yaml • installing production dependencies platform=win32 arch=x64 appDir=D:\jobs\electron\pc-chat\dist • packaging platform=win32 arch=x64 electron=4.2.12 appOutDir=release\win-unpacked • downloading url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.5.0/winCodeSign-2.5.0.7z size=5.6 MB parts=1 • retrying attempt=1 • retrying attempt=2 • retrying attempt=3 ⨯ part download request failed with status code 403 github.com/develar/app-builder/pkg/download.(*Part).doRequest /Volumes/data/Documents/app-builder/pkg/download/Part.go:126 github.com/develar/app-builder/pkg/download.(*Part).download /Volumes/data/Documents/app-builder/pkg/download/Part.go:67 github.com/develar/app-builder/pkg/download.(*Downloader).DownloadResolved.func1.1 /Volumes/data/Documents/app-builder/pkg/download/downloader.go:107 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.12.7/libexec/src/runtime/asm_amd64.s:1337 ⨯ D:\jobs\electron\pc-chat\node_modules\_app-builder-bin@3.4.3@app-builder-bin\win\x64\app-builder.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE stackTrace=
爲了更好更快的解決構建環境問題,須要咱們手動下載好electron環境的壓縮資源包等,構建好的打包緩存環境(存放手動下載資源包前,優先清除cache的緩存記錄)。node
eledtron緩存資源地址:~/AppData/Local/electron/Cache
git
electron-builder緩存資源地址:~/AppData/Local/electron-builder/Cache
github
下載好緩存資源包後,存儲到對應的cache文件中。npm
electron文件存儲方式:
json
electron-builder文件存儲方式:
segmentfault
nsis文件存儲方式:
緩存
winCodeSign存儲方式:
app
npm run build