linux下运行和打包electron项目遇到的错误处理(打包使用electron-builder)
记录一下由于windows下无法成功使用electron-builder打出linux包https://blog.csdn.net/weixin_42050406/article/details/106722691于是在linux下搞一搞首先是运行的时候peError: Cannot read property 'on' of undefinedat startElectron (/root/vi
记录一下
由于windows下无法成功使用electron-builder打出linux包
https://blog.csdn.net/weixin_42050406/article/details/106722691
于是在linux下搞一搞
纯记录,按照运行和打包遇到的问题写的,有弯路
具体处理方式建议直接看后半段
首先是运行的时候
peError: Cannot read property 'on' of undefined
at startElectron (/root/virt-access/virt-access/.electron-vue/dev-runner.js:148:26)
at /root/virt-access/virt-access/.electron-vue/dev-runner.js:200:7
at processTicksAndRejections (internal/process/task_queues.js:89:5)
events.js:173
throw er; // Unhandled 'error' event
^
Error: spawn /root/virt-access/virt-access/node_modules/electron/dist/electron.exe EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:249:19)
at onErrorNT (internal/child_process.js:442:16)
at processTicksAndRejections (internal/process/task_queues.js:84:9)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:255:12)
at onErrorNT (internal/child_process.js:442:16)
at processTicksAndRejections (internal/process/task_queues.js:84:9)
卸载依赖重装√
注:如果遇到权限问题 安装命令请执行sudo npm install
打包时遇到:
• downloading url=https://github.com/electron/electron/releases/download/v2.0.18/electron-v2.0.18-linux-arm64.zip size=48 MB parts=8
• 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:141
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.14.2_1/libexec/src/runtime/asm_arm.s:857
⨯ /root/virt-access/virt-access/node_modules/app-builder-bin/linux/arm/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE stackTr
ace= Error
: /root/virt-access/virt-access/node_modules/app-builder-bin/linux/arm/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE a
t ChildProcess.<anonymous> (/root/virt-access/virt-access/node_modules/builder-util/src/util.ts:243:14) a
t Object.onceWrapper (events.js:284:20) a
t ChildProcess.emit (events.js:196:13) a
t maybeClose (internal/child_process.js:1011:16) a
t Process.ChildProcess._handle.onexit (internal/child_process.js:268:5)
这个问题在windows打包也遇到过,就是网络问题
把需要的文件直接放到缓存里
文件可以在这个链接下载:https://npm.taobao.org/mirrors/electron/
electron淘宝镜像:https://npm.taobao.org/mirrors/electron/
结果又遇到新报错
• Electron 4 and higher is highly recommended for Snap
• application Linux category is set to default "Utility" reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux
• application Linux category is set to default "Utility" reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux
⨯ snapcraft is not installed, please: sudo snap install snapcraft --classic
• downloading url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z size=1.6 MB parts=1
• downloaded url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z duration=2m44.254s
⨯ /root/virt-access/virt-access/node_modules/app-builder-bin/linux/arm/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE stackTrace=
Error: /root/virt-access/virt-access/node_modules/app-builder-bin/linux/arm/app-builder exited with code ERR_ELECTRON_BUILDER_CAN
NOT_EXECUTE at ChildProcess.<anonymous> (/root/virt-access/virt-access/node_modules/builder-util/src/util.ts:243:14)
at Object.onceWrapper (events.js:284:20)
at ChildProcess.emit (events.js:196:13)
at maybeClose (internal/child_process.js:1011:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:5)
参考https://github.com/electron-userland/electron-builder/issues/4629
将builder版本降低到21.2.0(没用)
按照报错提示运行
snap install snapcraft --classic
结果遇到
-bash: snap: command not found
安装snap
sudo apt-get install snapd
结果遇到
真是错错无穷也
网上说是软件源未更新造成的,于是执行:sudo apt-get update 来更新软件源
等它更新完,再执行安装命令sudo snap install snapcraft --classic
继续报错- Download snap “core” (9668) from channel “stable” (read tcp 10.30.61.186:50756->91.189.88.179:443: read: connection reset by peer)
应该是网络问题,重试几下就好
上面这个命令又报错
error: cannot perform the following tasks:
- Mount snap "core" (9668) ([start snap-core-9668.mount] failed with exit status 1: Job for snap-core-9668.mount failed.
See "systemctl status snap-core-9668.mount" and "journalctl -xe" for details.
)
一路报错,太心累了
根据提示 查看详细内容journalctl -xe
看样子是没有xz这个压缩解压工具??
使用命令apt-get install xz-utils
结果还是报之前的错,根据提示,使用命令systemctl status snap-core-9668.mount查看详情
放两个参考链接
https://github.com/lxc/lxd/issues/3421
一样的错误,但别人update源之后就能成功安装,然而我不行,我还用了sudo apt-get upgrade
apt-get update 是更新本地软件列表,在线安装的时候可以在软件列表找到软件; apt-get upgrade 是更新本地已安装的软件,要谨慎执行。
感觉不应该执行sudo apt-get upgrade呢
但依然报错E: Unable to locate package squashfuse
我好像犯了一个致命错误
这是我的打包命令
使用uname -a查看当前linux系统架构
其实是armv7l的。难道是因为这个所以才一直报错吗??
修改命令,重装依赖,接着试
以下是实际操作中容易遇到打包问题:
下载appimage-12.0.1.7z失败
? Get https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z: dial tcp 13.250.177.223:443: connect: connection timed out
下载snap-template-electron-4.0-1-armhf.tar.7z失败
⨯ Get https://github.com/electron-userland/electron-builder-binaries/releases/download/snap-template-4.0-1/snap-template-electron-4.0-1-armhf.tar.7z: dial tcp
52.74.223.119:443: connect: connection timed out
根据链接,把对应的文件下载
新建文件夹appimage
新建文件夹snap、snap-template-electron-4.0-1-armhf
将下载的内容解压到对应的文件夹下
(PS:只有x86下打包才需要用到snap,但没有snap会打包失败)
重新安装
继续报错
? cannot execute cause=exit status 1
errorOut=/root/.cache/electron-builder/appimage/appimage-12.0.1/linux-arm32/mksquashfs: Compressor “xz” is not supported!
这个问题有点绝,说是appimage的mksquashfs不支持xz
啊???
修改打包命令,试试node .electron-vue/build.js && electron-builder --linux
报错变了
Unsupported arch arm stackTrace=
Error: Unsupported arch arm
at archFromString (/root/virt-access/virt-access/node_modules/builder-util/src/arch.ts:43:13)
真是错错无穷
然后我想去看下这一系列打出来的错误内容是什么
打包出来了一个.AppImage文件
???不是一直报错吗
所以最后也依然没能解决那个Compressor “xz” is not supported!(我感觉是装的appimage的问题),但能够打包成功且能运行了。
附上armv7l下的打包命令:
"linux": “node .electron-vue/build.js && electron-builder --linux --armv7l”,
“armv7l”:“node .electron-vue/build.js && electron-builder --armv7l”,
打包X86时遇到报错
• application Linux category is set to default “Utility” reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux
• application Linux category is set to default “Utility” reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux
⨯ Get https://github-production-release-asset-2e65be.s3.amazonaws.com/65527128/d119cd00-a2ff-11e9-967c-61940bcc6373?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA
IWNJYAX4CSVEH53A%2F20200910%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200910T054925Z&X-Amz-Expires=300&X-Amz-Signature=9b8b5524e52ebf4aa05828d64d3b238bc04eafd04c4fac3f0c6a7a0c339e7323&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=65527128&response-content-disposition=attachment%3B%20filename%3Dsnap-template-electron-4.0-2-amd64.tar.7z&response-content-type=application%2Foctet-stream: EOFgithub.com/develar/app-builder/pkg/download.(*Downloader).follow.func1
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:158
github.com/develar/app-builder/pkg/download.(*Downloader).follow
这个报错说得很清楚了,跟之前遇到的问题一样
打包时下载snap-template-electron-4.0-2-amd64.tar.7z失败了
下载地址:https://github.com/electron-userland/electron-builder-binaries/releases/download/snap-template-4.0-2/snap-template-electron-4.0-2-amd64.tar.7z
下载后解压放到/snap文件夹下即可
打包就不会报错了
X86解决√
感觉linux下的打包值得再看下
使用electron-packager打包没有遇到报错,但打包出来的无法使用
补充
以下是官方文档中对于electron支持的平台介绍:
OS X
对于 OS X 系统仅有64位的二进制文档,支持的最低版本是 OS X 10.8。
Windows
仅支持 Windows 7 及其以后的版本,之前的版本中是不能工作的。
对于 Windows 提供 x86 和 amd64 (x64) 版本的二进制文件。需要注意的是 ARM 版本的 Windows 目前尚不支持.
Linux
预编译的 ia32(i686) 和 x64(amd64) 版本 Electron 二进制文件都是在 Ubuntu 12.04 下编译的,arm 版的二进制文件是在 ARM v7(硬浮点 ABI 与 Debian Wheezy 版本的 NEON)下完成的。
预编译二进制文件是否能够运行,取决于其中是否包括了编译平台链接的库,所以只有 Ubuntu 12.04 可以保证正常工作,但是以下的平台也被证实可以运行 Electron 的预编译版本:
Ubuntu 12.04 及更新
Fedora 21
Debian 8
更多推荐
所有评论(0)