1
votes

I'm trying to build an electron app with sqlite3 .Now I'm trying to use electron builder for sqlite3 but I'm getting errors even after adding postinstall dependencies :

My package.json :

{
  "name": "store_electron",
  "version": "1.0.0",
  "description": "trying ",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "postinstall": "install-app-deps"
  },
  "author": "[email protected]",
  "license": "ISC",
  "dependencies": {
    "sqlite3": "^4.2.0"
  },
  "devDependencies": {
    "electron-builder": "^22.7.0",
    "electron-rebuild": "^1.11.0"
  }
}

The error I'm getting after tryied : npm run postinstall

> install-app-deps

  • please use as subcommand: electron-builder install-app-deps
  • electron-builder  version=22.7.0
Error: Cannot compute electron version from installed node modules - none of the possible electron modules are installed.
See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246
    at computeElectronVersion (C:\Users\boureima\Desktop\store_electron\node_modules\app-builder-lib\src\electron\electronVersion.ts:100:11)
    at getElectronVersion (C:\Users\boureima\Desktop\store_electron\node_modules\app-builder-lib\src\electron\electronVersion.ts:23:10)
    at async Promise.all (index 1)
    at installAppDeps (C:\Users\boureima\Desktop\store_electron\node_modules\electron-builder\src\cli\install-app-deps.ts:52:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `install-app-deps`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\boureima\AppData\Roaming\npm-cache\_logs\2020-06-04T10_37_40_435Z-debug.log

When using "postinstall": "electron-builder install-app-deps": I'm getting this :

 ⨯ Cannot compute electron version from installed node modules - none of the possible electron modules are installed.
See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: ` electron-builder install-app-deps`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\boureima\AppData\Roaming\npm-cache\_logs\2020-06-04T11_42_02_139Z-debug.log
1
Does this answer your question? How to use sqlite3 module with electron? - Mehdi Dehghani

1 Answers

0
votes

Please check this post https://bitfrit.com/how-to-use-sqlite-with-electron/

By far the easiest way to use SQLite with electron is withelectron-builder.

First, add a postinstall step in your package.json

"scripts": {
   "postinstall": "electron-builder install-app-deps"
   ...
 }
"devDependencies": {
   "electron": "6.0.11",
   "electron-builder": "^21.2.0",
   ....
 }

and then install the necessary dependencies and build:

npm install --save-dev electron-builder
npm install --save sqlite3
npm run postinstall

electron-builder will build the native module for your platform, with the correct name for the Electron binding; and you can then requireit in code as normal.