Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using better-sqlittte3 for electron app #1028

Closed
YmilitaryM opened this issue Jun 29, 2023 · 7 comments
Closed

using better-sqlittte3 for electron app #1028

YmilitaryM opened this issue Jun 29, 2023 · 7 comments

Comments

@YmilitaryM
Copy link

YmilitaryM commented Jun 29, 2023

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)

@neoxpert
Copy link
Contributor

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?

@YmilitaryM
Copy link
Author

3q for your answer! I found the error that not import 'sqslite3' but require('sqlite3'), but i don't know why

@YmilitaryM
Copy link
Author

at beginning ,
import sqlite3 from 'sqlite3'
but this is error
final
const sqlite3 = require('sqlite3')
that's ok!

@Prinzhorn
Copy link
Contributor

sqlite3 is an entirely different package from this one, see https://github.com/TryGhost/node-sqlite3

@NathanaelA
Copy link

#974 will fix most issues with Electron,

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.

@mceachen
Copy link
Member

(closing: issue is for a different package)

@NathanaelA
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants