使用电子生成器构建电子应用程序后,我无法从 dist 文件夹中打开该应用程序。我确实更改了所有链接以使用 path.join(__dirname, "relative_path/") 作为我在此处的一些答案中看到的内容。但是打包成功了还是打不开应用。
File structure for the electron app project
这是我的 file structure
的图像,这是项目的 package.json
文件
{
"name": "my_little_reminder",
"version": "0.5.0",
"description": "A simple time reminder app",
"main": "src/index.js",
"scripts": {
"start": "electron .",
"test": "jest --coverage",
"build": "electron-builder --dir"
},
"author": "Leonlit",
"license": "MIT",
"dependencies": {
"node-notifier": ">=8.0.1",
"node-schedule": "^1.3.2",
"sqlite3": "^5.0.0",
"electron-log": "^4.3.1"
},
"devDependencies": {
"electron": "^11.2.1",
"electron-builder": "^22.9.1",
"jest": "^26.6.3"
}
}
最后,如果这里的信息不够,这里是存储库的链接,https://github.com/Leonlit/My-Little-Reminder/tree/development
答案 0 :(得分:0)
通过添加和使用 npm 脚本 "postinstall": "electron-builder install-app-deps"
解决了该问题。
然后,使用 path.join(app.getPath('userData'), '/tasks.db')
而不是 path.join(__dirname, '/tasks.db')
作为 sqlite 数据库存储位置。
最后,更改了索引文件中的一个链接,导致应用程序在未修复的情况下始终请求在应用程序启动时保存 ASAR 文件。