In my electron app I want to package knex to use an sqlite3 database.
My package.json file
{
"name": "p",
"version": "1.0.0",
"description": "T",
"main": "main.js",
"scripts": {
"start": "electron .",
"package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",
"package-win": "electron-packager . electron-tutorial-app --overwrite --asar=true --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"PlanGo\"",
"package-linux": "electron-packager . electron-tutorial-app --overwrite --asar=true --platform=linux --arch=x64 --icon=assets/icons/png/icon.png --prune=true --out=release-builds",
"rebuild": "electron-rebuild -f -w sqlite3"
},
"author": "R",
"license": "MIT",
"dependencies": {
"custom-electron-titlebar": "^3.2.4",
"jquery": "^3.5.1",
"knex": "^0.21.6",
"sqlite3": "^5.0.0"
},
"devDependencies": {
"electron-packager": "^15.1.0",
"electron-rebuild": "^2.2.0",
"electron": "^10.1.3"
}
}
I have followed the following tutorial to package my app https://www.christianengvall.se/electron-packager-tutorial/
I'm answering this question myself because I was able to package it
Firstly, I used "electron-builder": "^22.9.1"
, instead of electron-packager
.
Next, the reason it wasn't being packaged is because the storage location of my app data wasn't specified properly.
I was using sqlite database and a json file.
On windows you have make sure it gets saved under APP DATA > your foldername. Electron will handle this automatically if you use
jsonPath = path.join(process.env.APPDATA, "/MyFileName/jsonFile.json");
This should solve any packaging errors you might face.