electron 报错:Application entry fi
2023-07-15 本文已影响0人
西叶web
场景
使用 electron-builder ,编写js脚本打包,报错
环境
"electron": "22.0.0",
"electron-builder": "^23.6.0",
相关代码
import * as electronBuilder from "electron-builder";
electronBuilder.build({
config: {
directories: {
output: outputDir,
app: appPathDir,
},
asar: true,
appId: "com.ikun.app",
productName: "electron-app",
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true,
},
},
});
报错
Application entry file "background.js" in the "D:\xxxxx\dist\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.
解决
electronBuilder.build({
config: {
directories: {
output: outputDir,
app: appPathDir,
},
asar: true,
appId: "com.ikun.app",
productName: "electron-app",
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true,
},
+++ files: ["background.js"],
},
});
原因
查看app.asar文件里少了background.js的内容