Open dector opened 1 month ago
Might be dupe for #15717
It's interesting! Libsql totally works!
$ deno eval "import Database from 'npm:libsql'; const db = new Database(':memory:'); console.log('Wow!')"
Wow!
The underlying reason is that better-sqlite3
uses internal node C++ APIs directly. Those are not stable across node versions (for instance, better-sqlite3 needs a different build for each node version, and internal changes in node can break it) and for this reason they aren't supported by deno.
If better-sqlite3
were updated to use NAPI, which is a stable interface for node native addons, instead of node's internal APIs it would work on deno.
Other packages (such as sqlite3 and libsql) do use NAPI, and so they work in deno
Thanks for the explanation!
I dunno how important part of the ecosystem is better-sqlite3
but libsql
is quite awesome.
Feel free to close this issue as "wan't fix".
It is technically possible to emulate Node.js NaN and expose V8 C++ symbols. There are usually not any breaking changes to old V8 APIs that modules like better-sqlite3
might be using.
Same issue here :( deno eval "import Database from 'npm:better-sqlite3'; const db = new Database(':memory:'); console.log('Wow!')"
Warning experimentalDecorators compiler option is deprecated and may be removed at any time
error: Uncaught (in promise) TypeError: LoadLibraryExW failed: A dynamic link library (DLL) initialization routine failed. (os error 1114)
at Object.Module._extensions..node (node:module:807:20)
at Module.load (node:module:662:32)
at Function.Module._load (node:module:534:12)
at Module.require (node:module:681:19)
at require (node:module:818:16)
at bindings (file:///D:/NodeJS/***/***/node_modules/.deno/bindings@1.5.0/node_modules/bindings/bindings.js:112:48)
at new Database (file:///D:/NodeJS/***/***/node_modules/.deno/better-sqlite3@11.5.0/node_modules/better-sqlite3/lib/database.js:48:64)
at file:///D:/NodeJS/***/***/apps/backend/$deno$eval.ts:1:55
WORKAROUND
If you don't mind WAL mode - use
libsql
instead (it's compatible withbetter-sqlite3
API):Original issue
This issue was raised earlier in #18444 and #19130 but was closed as "fixed". However, it's not.