Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
540 views
in Technique[技术] by (71.8m points)

Unable to open electron app after packaging the app using electron-builder

After building the electron application using electron-builder, I cannot open the application from the dist folder. I did change all my links to use path.join(__dirname, "relative_path/") as what I have seen in some answers here. But I can't open the application even though the packaging process is successful.

File structure for the electron app project

Here's an image of my file structure, and this is the package.json file of the project

{
  "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"
  }
}

Finally, here's a link to the repository if the information here is not enough, https://github.com/Leonlit/My-Little-Reminder/tree/development

question from:https://stackoverflow.com/questions/65895747/unable-to-open-electron-app-after-packaging-the-app-using-electron-builder

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Resolved the issue by adding and using the npm script "postinstall": "electron-builder install-app-deps".

Then, using path.join(app.getPath('userData'), '/tasks.db') instead of path.join(__dirname, '/tasks.db') for the sqlite database storage location.

Finally, changed a link in the index file which caused the application to always request for saving a ASAR file on app launch if left unfixed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...