drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.51k stars 643 forks source link

[BUG]: Could not locate the bindings file for better_sqlite3 in bun #1461

Open dillondotzip opened 1 year ago

dillondotzip commented 1 year ago

What version of drizzle-orm are you using?

v0.28.6

What version of drizzle-kit are you using?

v0.19.13

Describe the Bug

I'm trying to run bun --bun drizzle-kit push:sqlite but get the following error:

error: Could not locate the bindings file. Tried:
→ /Users/***/Desktop/***/node_modules/better-sqlite3/build/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/build/Release/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/Debug/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/out/Release/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/Release/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/build/default/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/compiled/20.8.0/darwin/arm64/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
→ /Users/***/Desktop/***/node_modules/better-sqlite3/lib/binding/node-v115-darwin-arm64/better_sqlite3.node
      at bindings (/Users/***/Desktop/***/node_modules/bindings/bindings.js:126:8)
      at new Database (/Users/***/Desktop/***/node_modules/better-sqlite3/lib/database.js:48:28)
      at _createClient (/Users/***/Desktop/***/node_modules/drizzle-kit/index.cjs:43506:13)
      at _createClient4 (/Users/***/Desktop/***/node_modules/drizzle-kit/index.cjs:51839:11)
      at createClient (/Users/***/Desktop/***/node_modules/drizzle-kit/index.cjs:51834:9)
      at /Users/***/Desktop/***/node_modules/drizzle-kit/index.cjs:51888:12
      at connectToSQLite (/Users/***/Desktop/***/node_modules/drizzle-kit/index.cjs:51878:29)
      at /Users/***/Desktop/***/node_modules/drizzle-kit/index.cjs:53433:27
      at processTicksAndRejections (:55:76)

This is my drizzle.config.ts file:

import { type Config } from 'drizzle-kit';
import path from 'path';

const dbPath = path.resolve(__dirname, 'src', 'myDatabase.db');

export default {
    out: './migrations',
    schema: './src/schema.ts',
    breakpoints: true,
    driver: "libsql",
    dbCredentials: {
        url: Bun.env.DB_URL || `file:${dbPath}`
    }
} satisfies Config;

Expected behavior

No response

Environment & setup

No response

tindecken commented 1 year ago

the same issue with pull action in Node.js v19.4.0, on Raspberry Pi 4

image

juretopolak commented 1 year ago

Same error using: bunx --bun drizzle-kit push:sqlite

bun: 1.0.11
drizzle-kit: v0.20.2
drizzle-orm: v0.29.0

After deleting node_modules folder and installing dependencies with yarn command works as expected: yarn drizzle-kit push:sqlite

domosedov commented 7 months ago

Run bun pm untrusted

Output:

[0.20ms] ".env"
bun pm untrusted v1.1.3 (2615dc74)

./node_modules/better-sqlite3 @9.5.0
 » [install]: prebuild-install || node-gyp rebuild --release

./node_modules/esbuild @0.19.12
 » [postinstall]: node install.js

./node_modules/@esbuild-kit/core-utils/node_modules/esbuild @0.18.20
 » [postinstall]: node install.js

These dependencies had their lifecycle scripts blocked during install.

If you trust them and wish to run their scripts, use `bun pm trust`.

Resolve problem bun pm trust --all

Output:

[0.05ms] ".env"
bun pm trust v1.1.3 (2615dc74)
esbuild [1/3] 
better-sqlite3 [2/3] 
esbuild [2/3] 
esbuild [4/3] 

./node_modules/@esbuild-kit/core-utils/node_modules/esbuild @0.18.20
 ✓ [postinstall]: node install.js

./node_modules/better-sqlite3 @9.5.0
 ✓ [install]: prebuild-install || node-gyp rebuild --release

./node_modules/esbuild @0.19.12
 ✓ [postinstall]: node install.js

 3 scripts ran across 3 packages [647.00ms]