happy easter,
Trying to create a build for mac osx, also working on a mac.
This is a part of my package.json to show what i use (based on electron-boilerplate-sqlite):
"dependencies": {
"sqlite3": "^3.1.8"
},
"devDependencies": {
"electron": "^1.6.2",
"electron-builder": "^10.17.3"
}
This is how i set the path to the db-file
const dbFile = path.join(__dirname, '/appData.db');
In the build the path is like this:
/Users/[USERNAME]/[PATH-TO-CONTENT]/Contents/Resources/app.asar/app/appData.db
... and I end up with an error:
SQLITE_CANTOPEN: unable to open database file
Now setting asar to false in the build-options. The path is now like this:
/Users/[USERNAME]/[PATH-TO-CONTENT]/Contents/Resources/app/app/appData.db
The app works fine.
How can i solve this problem?
regards, jo
Please use extraResources https://github.com/electron-userland/electron-builder/wiki/Options#Config-extraResources
thanks for the hint, but it seems to be not very handy... i end up here:
"extraResources": ["appData.db"],
and here:
const dbFile = path.join(__dirname, '/appData.db').replace('/app.asar', '');
hmmm...
Update: add examples to doc.
@wende60
"extraResources": ["appData.db"],
Did it work?
as mentioned above, it works only if i toggle the path like here:
const dbFile = path.join(__dirname, '/appData.db').replace('/app.asar', '');
I stopped testing here as I switched to a completely different setup using pouchdb...
cheers, jo
Fix on electron side is required. https://www.npmjs.com/package/hazardous
cool, thanks :)
"extraResources": ["appData.db"],
and
const dbFile = path.join(__dirname, '/appData.db').replace('/app.asar', '');
Worked for me!!!
Most helpful comment
thanks for the hint, but it seems to be not very handy... i end up here:
"extraResources": ["appData.db"],and here:
const dbFile = path.join(__dirname, '/appData.db').replace('/app.asar', '');
hmmm...