1

I have an electron app which uses a database opened with the following code:

const fs = require("fs")
const sqlite = require("aa-sqlite")
await sqlite.open('cregr_db.db');

My package.json contains :

  "build": {
    "appId": "crergr",
    "linux": {
      "target": [
        "AppImage"
      ],
      "icon": "icon512.png"
    },
    "win": {
      "target": "NSIS",
      "icon": "icon256.ico"
    },
    "extraFiles": [
      "cregr_db.db"
    ]
  },

the cregr_db.db is in the same folder as my *js, index.html and style.css. Everything runs fine when launched from the root directory of my app.

If I run the app image from elsewhere, I have an exception when I query the database and, in fact, the database file is not displayed in the file hierarchy. I can not post an image here but you can find one at http://alainbe.free.fr/files.png What I am doing wrong ? Thanks for your help.

1 Answer 1

1

In fact, the db file was probably added but in an ASAR archive so can't be read by the code posted above.

The solution I chose was to distribute the app without building an ASAR archive and in this case, everything works exactly like you are testing your app (tested on Linux and Windows).

There is a strong warning about building an app without an ASAR. I chose not to pay attention because any way there are ways to unpack the ASAR and see the code and besides, my app is GPL'ed.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.