better-sqlite3: TypeError: Cannot read property 'indexOf' of undefined when I run my electron app
Hi better-sqlite3
I try to run a fresh install of electron which contain your better library.
in my my process electron file (background.ts) I added those 2 lines :
import Database from 'better-sqlite3'
const db = new Database('foobar.db', { verbose: console.log });
If a just launch the first line I have no problem. But If I launch those 2 lines I have this error when I run my electron app.
` INFO Launching Electron…
App threw an error during load
TypeError: Cannot read property ‘indexOf’ of undefined at Function.getFileName (webpack:///./node_modules/bindings/bindings.js?:178:16) at bindings (webpack:///./node_modules/bindings/bindings.js?:82:48) at eval (webpack:///./node_modules/better-sqlite3/lib/database.js?:9:79) at Object…/node_modules/better-sqlite3/lib/database.js (/Users/xxxx/xxxxx/xxxxxx/dist_electron/index.js:133:1) at webpack_require (/Users/xxxxxx/xxxxx/xxxxx/dist_electron/index.js:20:30) at eval (webpack:///./node_modules/better-sqlite3/lib/index.js?:2:18) at Object…/node_modules/better-sqlite3/lib/index.js (/Users/xxxxxx/xxxxxx/xxxxxxx/dist_electron/index.js:157:1) at webpack_require (/Users/xxxxx/xxxxx/xxxxxx/dist_electron/index.js:20:30) at eval (webpack:///./src/background.ts?:7:72) at Module…/src/background.ts (/Users/xxxxxx/xxxxxx/xxxxxx/dist_electron/index.js:1863:1) `
I electron-rebuild my app without issue…
Do you have an idea or a way to resolve this please ?
Technical information :
Electron : 10.1.5
node : 14.15.0
node-gyp : 7.1.2
TypeScript : 3.9.7
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (2 by maintainers)
Commits related to this issue
- Fix: Manage to serve and build the electron project The problem was with the better-sqlite3 package and it not being handled correctly in the vue.config More info here: https://github.com/WiseLibs/be... — committed to alfonso46674/TaskMan by alfonso46674 2 years ago
- 解决better-sqlit3 在 electron 中使用报错的问题 https://github.com/WiseLibs/better-sqlite3/issues/488#issuecomment-727549367 — committed to xiyuesaves/imghub by xiyuesaves 2 years ago
@darkomenx Hi! Here is my solution.
npm run rebuild
it really works!!!