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

deno --compat mode cannot find bindings file #13253

Closed
andykais opened this issue Dec 31, 2021 · 8 comments
Closed

deno --compat mode cannot find bindings file #13253

andykais opened this issue Dec 31, 2021 · 8 comments

Comments

@andykais
Copy link

I am trying to get the better-sqlite3 module running in compat mode. Here is the script I am attempting to run:

import { createRequire } from "https://deno.land/std@0.118.0/node/module.ts";
const require = createRequire(import.meta.url);

const Sqlite = require('better-sqlite3')
console.log({ Sqlite })

Deno errors out saying it is not able to find the bindings file:

 andrew  forager  deno run --compat --unstable --allow-net --allow-read --allow-env sample.ts
error: Uncaught Error: Could not locate the bindings file. Tried:
 → /home/andrew/Code/development/forager/node_modules/bindings/build/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/build/Debug/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/build/Release/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/out/Debug/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/Debug/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/out/Release/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/Release/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/build/default/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/compiled/16.11.1/linux/x64/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/addon-build/release/install-root/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/addon-build/debug/install-root/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/addon-build/default/install-root/better_sqlite3.node
 → /home/andrew/Code/development/forager/node_modules/bindings/lib/binding/node-v93-linux-x64/better_sqlite3.node
  err = new Error(
        ^
    at bindings (file:///home/andrew/Code/development/forager/node_modules/bindings/bindings.js:126:9)
    at Object.<anonymous> (file:///home/andrew/Code/development/forager/node_modules/better-sqlite3/lib/database.js:9:24)
    at Module._compile (https://deno.land/std@0.118.0/node/module.ts:252:36)
    at Object.Module._extensions..js (https://deno.land/std@0.118.0/node/module.ts:1276:10)
    at Module.load (https://deno.land/std@0.118.0/node/module.ts:231:34)
    at Function._load (https://deno.land/std@0.118.0/node/module.ts:540:14)
    at Module.require (https://deno.land/std@0.118.0/node/module.ts:217:21)
    at require (https://deno.land/std@0.118.0/node/module.ts:1331:16)
    at Object.<anonymous> (file:///home/andrew/Code/development/forager/node_modules/better-sqlite3/lib/index.js:2:18)
    at Module._compile (https://deno.land/std@0.118.0/node/module.ts:252:36)

the bindings files were actually in these locations:

 ✘ andrew  forager  find node_modules -name better_sqlite3.node
node_modules/better-sqlite3/build/Release/better_sqlite3.node
node_modules/better-sqlite3/build/Release/obj.target/better_sqlite3.node

and here when node_modules was installed with pnpm (which I use over npm when I can):

 andrew  forager  find node_modules -name better_sqlite3.node
node_modules/.pnpm/better-sqlite3@7.4.3/node_modules/better-sqlite3/build/Release/better_sqlite3.node
node_modules/.pnpm/better-sqlite3@7.4.3/node_modules/better-sqlite3/build/Release/obj.target/better_sqlite3.node
@andykais
Copy link
Author

related to this parent issue I suppose #12577

@bartlomieju
Copy link
Member

This is a design limitation that most likely we won't be able to overcome. Native modules are totally incompatible between Node and Deno. The error message should be better, stating that this won't work instead of Could not locate the bindings file. Tried:

@bartlomieju bartlomieju added node compat design limitation something that can't be fixed or is too hard to fix labels Jan 4, 2022
@andykais
Copy link
Author

andykais commented Jan 4, 2022

ok thanks for clarifying. Ill let you decide if this issue should be closed or left open.

@stale
Copy link

stale bot commented Mar 6, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 6, 2022
@bartlomieju bartlomieju removed design limitation something that can't be fixed or is too hard to fix stale labels Mar 6, 2022
@bartlomieju
Copy link
Member

@littledivy is working on NAPI integration, so this should be somewhat possible

@littledivy
Copy link
Member

Unfortunately better-sqlite3 is writing in NAN (Native Abstractions for Node.js) and not NAPI (Node-API). You will be able to run mapbox/node-sqlite3 when we land NAPI integration.

@andykais
Copy link
Author

andykais commented Mar 7, 2022

ah gotcha. In this particular case I would probably pick up one of deno's sqlite libraries rather than use mapbox/node-sqlite3. Thanks for your work on this all the same though @littledivy!

@stale
Copy link

stale bot commented May 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 31, 2022
@stale stale bot closed this as completed Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants