My Notes

Fishing, Golfing and Programming

Pack and distribute an ionic electron app with a pre-filled sqlite database for windows 10

Posted by Ahchi on Aug 30, 2017


In order to distribute an electron desktop application with a pre-filled database
I have found two problems
- Native module (e.g. SQLite) needs to be compiled to the target platform (e.g. Win 10)
- the database is read only



Inside the package.json

 "scripts": {
    "postinstall": "electron-builder install-app-deps",
    "pack": "electron-builder --dir && npm run copydata",
    "copydata": "cp -r ./data ./dist/win-unpacked/data && echo 'Database files copied.'",
    "prepack": "electron-builder --prepackaged ./dist/win-unpacked",
    "dist": "npm run pack && npm run prepack",


1. Make a “data” directory
2. Copy the pre-filled database to the “data” directory
3. npm run dist



Testing Environment

Node : v8.1.3
Npm : v5.3.0
Electron : v1.7.5
Electron-builder: v19.22.2
Ionic : v3.6.0
Angular : v4.1.3
SQLite : v2.8.0
Typescript: : v2.3.4


References and Credits

To add Sqlite support for electron

For electron and ionic integration



Desert Sky by Silent Partner