摘要
從GitLab上拉取專案代碼后,運行命令
npm run build構建electron打包環境時,由于某些原因(可能被某些墻阻止等),構建環境失敗,出現超時錯誤,錯誤代碼如下:
錯誤代碼段參考自:https://segmentfault.com/q/1010000022013746
? 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\[email protected]@app-builder-bin\win\x64\app-builder.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE stackTrace=
解決方案
為了更好更快的解決構建環境問題,需要我們手動下載好electron環境的壓縮資源包等,構建好的打包快取環境(存放手動下載資源包前,優先清除cache的快取記錄),
方案具體步驟
- 清除electron和electron-builder的cache快取記錄(洗掉檔案夾中舊的快取資源包),
-
eledtron快取資源地址:
~/AppData/Local/electron/Cache -
electron-builder快取資源地址:
~/AppData/Local/electron-builder/Cache
- 根據錯誤提示一步一步的手動下載資源包(資源包版本直接下載當前提示的可用版本,具體類似下圖所示下載鏈接),

-
下載好快取資源包后,存盤到對應的cache檔案中,
-
electron檔案存盤方式:

-
electron-builder檔案存盤方式:

-
nsis檔案存盤方式:

-
winCodeSign存盤方式:

-
- 重新運行命令
npm run build
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/14874.html
標籤:JavaScript
下一篇:vue生命周期理解(粗略總結)
