项目架构:vue3+vite+ts
electron版本:^33.2.0
电脑系统: macOs m1芯片版
根据现有的各种文档,在package.json中配置了
bash
"electron:build": "vite build & electron-builder build --config electron-builder.json"
命令,但是在执行
bash
pnpm electron:build
的时候,发现总是报错,打包出的文件程序中无法重命名app名称
bash
ENOENT: no such file or directory, rename
'xxxxxxxx/vue3-vite-electron/buileder/mac/Electron.app/Contents/MacOS/Electron'
-> 'xxxxxx/vue3-vite-electron/buileder/mac/Electron.app/Contents/MacOS/Electron' failedTask=build stackTrace=Error: ENOENT: no such file or directory, rename........
于是查看内部执行语句,发现了:
bash
• completed installing native dependencies
• packaging platform=darwin arch=x64 electron=33.2.0
appOutDir=buileder/mac
• default Electron icon is used reason=application icon is not set
所以其实默认执行electron-builder的时候,没有正确的判断系统的电脑芯片类型。
更改为执行:(sudo可不加,跟电脑原有配置有关)。执行完可以正确生成安装包
bash
sudo pnpm electron:build --arm64