場(chǎng)景
使用 electron-builder ,編寫js腳本打包杭朱,報(bào)錯(cuò)
環(huán)境
"electron": "22.0.0",
"electron-builder": "^23.6.0",
相關(guān)代碼
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,
},
},
});
報(bào)錯(cuò)
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的內(nèi)容