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 support - Uncaught Error: Could not locate the bindings file. #1034

Open
quantuminformation opened this issue Jul 27, 2023 · 9 comments · Fixed by denoland/deno#24727
Open

Comments

@quantuminformation
Copy link

Tried to use with deno

import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
import { drizzle } from 'drizzle-orm/better-sqlite3';
import Database from 'better-sqlite3';

const users = sqliteTable('users', {
  id: integer('id').primaryKey(), // 'id' is the column name
  fullName: text('full_name'),
});

const sqlite = new Database('sqlite.db');
const db = drizzle(sqlite);

const allUsers = db.select().from(users).all();
backend git:(master) ✗ deno task dev
Task dev deno run -A --unstable main.ts
error: Uncaught Error: Could not locate the bindings file. Tried:
 → /Users/nikos/WebstormProjects/vanillajs-patterns/backend/node_modules/.deno/bindings@1.5.0/node_modules/bindings/build/better_sqlite3.node
 → /Users/nikos/WebstormProjects/vanillajs-patterns/backend/node_modules/.deno/bindings@1.5.0/node_modules/bindings/build/Debug/better_sqlite3.node
 → /Users/nikos/WebstormProjects/vanillajs-patterns/backend/node_modules/.deno/bindings@1.5.0/node_modules/bindings/build/Release/better_sqlite3.node
@neoxpert
Copy link
Contributor

neoxpert commented Jul 29, 2023

Even if deno would run npm packages, like bindings, correctly, I doubt that it can load native modules compiled for NodeJS.

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Aug 4, 2023

I doubt that it can load native modules compiled for NodeJS.

Apparently it can denoland/deno#18444 denoland/deno#15717

But this is not a better-sqlite3 issue, it's on Deno to make it compatible if they want that.

@BrunoSette
Copy link

It doesn't work win Bun 1.0 either. Same error here:

ERROR: Could not locate the bindings file. Tried:

@neoxpert
Copy link
Contributor

neoxpert commented Sep 10, 2023

Which prebuilt binary did you download? Also note that Bun still does not support the full Node API which may lead to issues anyway support overview.

@quantuminformation
Copy link
Author

We are moving to bun 1.0, it appears to work

@xero
Copy link

xero commented Sep 21, 2023

It doesn't work win Bun 1.0 either.

bun has a native sqlite adapter. this project is cited as it’s inspiration

@CM-IV
Copy link

CM-IV commented Sep 24, 2023

You can use .node (Node-API modules) in both Deno and Bun, but you cannot do bun build --compile or deno compile with them. So that just means not building or compiling your code and just running the .ts file in production.

I have tried this on both Deno and Bun with my napi-rs created npm library that exports typed functions from a .node file.

@ducktype
Copy link

ducktype commented Feb 29, 2024

if i try to put the .node dynamic lib from:
https://github.com/WiseLibs/better-sqlite3/releases/download/v9.4.3/better-sqlite3-v9.4.3-node-v108-win32-x64.tar.gz
in:
\AppData\Local\deno\npm\registry.npmjs.org\bindings\1.5.0\lib\binding\node-v108-win32-x64\better_sqlite3.node
i get this error:
TypeError: LoadLibraryExW failed

Dependency walker on better_sqlite3.node shows an unresolved dependency "node.exe"
Could be related to not loading node-api at runtime in better_sqlite3.node?
something like said here: neon-bindings/neon#584
which will also avoid to have separate better_sqlite3.node binary releases for electron and node?

Or for some reason node-gyp win_delay_load_hook Is disabled?
https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules

Related?
barthofu/tscord#158

@deadcoder0904
Copy link

I solved it by installing better-sqlite3 in Dockerfile instead of package.json & using pnpm's supportedArchitectures feature.

marvinhagemeister pushed a commit to denoland/deno that referenced this issue Jul 26, 2024
Adds support for `npm:bindings` and `npm:callsites` packages because of
changes in
denoland/deno_core#838.

This `deno_core` bump causes us to stop prepending `file://` scheme for
locations
in stack traces that are for local files.

Fixes #24462 , fixes
#22671 , fixes
#15717 , fixes
#19130 , fixes
WiseLibs/better-sqlite3#1205 , fixes
WiseLibs/better-sqlite3#1034 , fixes
#20936

---------

Co-authored-by: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com>
dsherret pushed a commit to denoland/deno that referenced this issue Jul 26, 2024
Adds support for `npm:bindings` and `npm:callsites` packages because of
changes in
denoland/deno_core#838.

This `deno_core` bump causes us to stop prepending `file://` scheme for
locations
in stack traces that are for local files.

Fixes #24462 , fixes
#22671 , fixes
#15717 , fixes
#19130 , fixes
WiseLibs/better-sqlite3#1205 , fixes
WiseLibs/better-sqlite3#1034 , fixes
#20936

---------

Co-authored-by: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

9 participants