常见问题

Electron打包报错及electron-v27.1.2-win32-x64.zip下载慢的问题处理

常见问题

2600

字体:
  ⨯ Get "https://github.com/electron/electron/releases/download/v27.1.2/electron-v27.1.2-win32-x64.zip": read tcp 192.168.1.3:50598->20.205.243.166:443: wsarecv: A connection attempt failed because the connected party did not pro
perly respond after a period of time, or established connection failed because connected host has failed to respond.
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  
  ⨯ C:\Users\Administrator\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1  failedTask=build stackTrace=Error: C:\Users\Administrator\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:


以上报错使用的是 build 打包,需要手动安装 /electron-v27.1.2-win32-x64.zip文件

"scripts": {
    "start": "electron .",
	"packagewin": "electron-packager ./ spapi  --platform=win32 --out=./dist --arch=x64  --app-version=1.0.0 --icon=./static/login.ico --overwrite",
	"build": "electron-builder"
  },

需要packagewin需要安装electron-packager

npm install -g electron-packager

太麻烦了,然后我想使用 packagewin方法打包 会自动安装electron-v27.1.2-win32-x64.zip包,但是问题是 安装太慢


在网站找了下资料 说是镜像下就可以了,这样下载快些了,但是还是用了我5分钟

npm config set registry https://registry.npm.taobao.org/


打开hosts文件

hosts文件可以使用everything进行搜索,找到\Windows\Systems32\divers\etc下面这个hosts文件。把上面报错地址写入进去

192.168.1.3:50598->20.205.243.166:443


改
0 0 0 0 github.com

更新DNS缓存

在控制台输入以下代码,以更新DNS缓存

ipconfig /flushdns


最后还是无法正常打包。。。

[声明]原创不易,请转发者备注下文章来源(hbsjsd.cn)【速建时代】。