Skip to content

db:migrate fails with 'Could not locate the bindings file' (better-sqlite3) on fresh setup #25

Description

@mattpocock

Report

A student hit this running npm run db:migrate on a fresh clone, before any code changes:

npm run db:migrate

db:migrate
drizzle-kit migrate

No config path provided, using default 'drizzle.config.ts'
Reading config file '/workspace/drizzle.config.ts'
Error: Could not locate the bindings file. Tried:
 → /workspace/node_modules/better-sqlite3/build/better_sqlite3.node
...

Reported environment: npm v10.9.8, node v22.23.2, fresh git pull same day.

Note the path prefix /workspace/... — not a normal host clone path, so this may be happening inside Docker/a devcontainer/WSL rather than directly on the reporter's machine (unconfirmed).

Investigation so far

  • Reproduced a clean install in a throwaway copy of this repo (rm -rf node_modules && npm install && npm run db:migrate) on Linux x64 — worked fine. better-sqlite3's install step (prebuild-install || node-gyp rebuild --release) successfully downloaded a prebuilt binary from GitHub releases; no compile fallback was needed.
  • So this doesn't look like a broken lockfile or a repo-wide regression — it reproduces only in the reporter's environment.
  • better-sqlite3's install script downloads a prebuilt native binary over the network, falling back to a local node-gyp compile (needs python3 + a C/C++ toolchain) if that fails. If both the network fetch and the compile fallback fail/are skipped, npm install can exit 0 while leaving no .node binding — surfacing later as this exact error at db:migrate time rather than at install time.

Likely causes (unconfirmed — need more info from reporter)

  • Running inside a container/devcontainer/WSL where node_modules was built on a different OS/arch than the one actually executing db:migrate (classic bind-mount/cross-arch mismatch) — the /workspace path is the main clue pointing here.
  • No outbound network access to GitHub releases during npm install (corporate proxy/VPN/offline sandbox), combined with missing local build tools (python3/make/g++, or Windows build tools) for the compile fallback.
  • ignore-scripts set (globally or via npm config) so better-sqlite3's install script never runs at all.
  • Antivirus / cloud-sync (e.g. OneDrive) stripping the compiled .node binary after install.

Next steps

Asked the reporter to confirm:

  1. Whether they're running inside Docker/a devcontainer/WSL/cloud IDE, or /workspace is just their host folder name.
  2. The OS/arch actually executing the commands (host vs. container, if applicable).
  3. Output of:
    npm config get ignore-scripts
    rm -rf node_modules
    npm install --loglevel=verbose 2>&1 | grep -iE "better-sqlite3|prebuild|gyp"
    npm rebuild better-sqlite3 --verbose
    

Once we know the actual cause, this may turn into a README troubleshooting note for future students, since this is a plausible recurring pain point (native module install on varied student machines).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-infoWaiting on reporter for more information

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions