Closed YmilitaryM closed 1 year ago
Does not look like an better-sqlite3 issue but a rollup configuration problem of the ominous app that threw the error.
Can you provide more details?
3q for your answer! I found the error that not import 'sqslite3' but require('sqlite3'), but i don't know why
at beginning , import sqlite3 from 'sqlite3' but this is error final const sqlite3 = require('sqlite3') that's ok!
sqlite3
is an entirely different package from this one, see https://github.com/TryGhost/node-sqlite3
I've currently custom added a couple lines of JS code to my copy of better-sqlite to eliminate the above issue, but #974 will allow us to trivially make it work in Electron once it is merged.
(closing: issue is for a different package)
@mceachen - The original call stack actually is for better-sqlite3
. I think the dev must have tried several sqlite packages and initially reported correctly, but then started talking about other packages in his followup post since he was onto the next one just trying to get something to work....
If you read the first callstack:
Error: Could not dynamically require "$pwd/electron-vite/build/better_sqlite3.node". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
As an aside, I ran into the same issue as I also use Rollup in my electron build. That is why I originally posted #972 (because I had to hack #972 into my own copy of better-sqlite which I currently use) which should be fixed and allow me to use the stock better-sqlite in #974 when it is merged.
App threw an error during load Error: Could not dynamically require "$pwd/electron-vite/build/better_sqlite3.node". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work. at commonjsRequire (/Users/apple/work-dir/electron-vite/dist-electron/main.js:29:9) at bindings2 (/Users/apple/work-dir/electron-vite/dist-electron/main.js:166:52) at new Database$1 (/Users/apple/work-dir/electron-vite/dist-electron/main.js:797:64) at Object. (/Users/apple/work-dir/electron-vite/dist-electron/main.js:833:12)
at Module._compile (node:internal/modules/cjs/loader:1269:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1324:10)
at Module.load (node:internal/modules/cjs/loader:1124:32)
at Module._load (node:internal/modules/cjs/loader:965:12)
at f._load (node:electron/js2c/asar_bundle:2:13330)
at loadApplicationPackage (/Users/apple/work-dir/electron-vite/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:121:16)