Better-sqlite3: Error: Could not locate the bindings file. Tried:

Created on 29 Jul 2019  ยท  10Comments  ยท  Source: JoshuaWise/better-sqlite3

I am getting this error
โ†’ /home/container/node_modules/better-sqlite3/build/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/build/Release/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/Debug/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/out/Release/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/Release/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/build/default/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/compiled/10.15.1/linux/x64/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
โ†’ /home/container/node_modules/better-sqlite3/lib/binding/node-v64-linux-x64/better_sqlite3.node
at bindings (/home/container/node_modules/bindings/bindings.js:126:9)
at Object. (/home/container/node_modules/better-sqlite3/lib/database.js:4:40)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/home/container/node_modules/better-sqlite3/index.js:2:18)

I have looked at the the issues on the same stuff that people has had in the past and they do not work I have updated node-gyp and followed every download steps I have redownloaded and everything my system runs ubuntu 18.04 please help if you need to contact me on discord it is Carma Cam#1557

help wanted

Most helpful comment

This has been fixed in v7.0.0

All 10 comments

The error you're having is with the bindings npm module, which better-sqlite3 no longer uses. Try updating to the latest version of better-sqlite3.

The error you're having is with the bindings npm module, which better-sqlite3 no longer uses. Try updating to the latest version of better-sqlite3.

I am on the newest version of better-sqlite3

@ItsCam57 Which version is that, specifically?

Closing due to inactivity.

i'm using 6.0.1 (the latest, right?) and i'm seeing this issue. also, what do you mean that it no longer uses the bindings module? https://github.com/JoshuaWise/better-sqlite3/blob/66fcb8675b9420ffe0c4851627a3ca7b6cf78de6/package.json#L13

@keithbentrup At the time of my comment, better-sqlite3 didn't use the bindings module. Now it does again. Take a look at your build directory to find out why bindings couldn't find the binary. Run find build and post the results here.

@JoshuaWise There was no build dir, and during installation, I guess node-gyp rebuild was silently failing.

I recently started using fnm (a node version manager similar to nvm but compatible with the fish shell, too) on this project, so now there's no global node-gyp. As more people require multiple versions of node, any dependency (including build ones) should probably be explicitly stated in the package.json and that local node-gyp version should be used for building. (Of course, maybe you've already considered this, and there's a good reason that it won't work or isn't recommended in this case)

Anyway, I'll try to further troubleshoot b/c now even if I add node-gyp as dependency on my project and try to run ../node-gyp/bin/node-gyp.js rebuild from the better-sqlite3 dir, better-sqlite3 appears to build fine (with a few warnings), but my project isn't working as before. Instead of the Could not locate the bindings file, I see many new errors with hex addresses.

FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
 1: 0x10003c597 node::Abort() [/var/folders/_c/xmm7nnpn6vn20s30bnsy94qw0000gn/T/fnm-shell-2342283/bin/node]
 2: 0x10003c7a1 node::OnFatalError(char const*, char const*) [/var/folders/_c/xmm7nnpn6vn20s30bnsy94qw0000gn/T/fnm-shell-2342283/bin/node]
 3: 0x1001afce0 v8::V8::ToLocalEmpty() [/var/folders/_c/xmm7nnpn6vn20s30bnsy94qw0000gn/T/fnm-shell-2342283/bin/node]
 4: 0x10310f869 Require(v8::Local<v8::Object>, char const*) [/Users/kbentrup/mcm/cli/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
 5: 0x1031115fb Integer::Init(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Object>) [/Users/kbentrup/mcm/cli/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
 6: 0x10311971f RegisterModule(v8::Local<v8::Object>, v8::Local<v8::Object>) [/Users/kbentrup/mcm/cli/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
 7: 0x10003ffc6 node::DLOpen(v8::FunctionCallbackInfo<v8::Value> const&) [/var/folders/_c/xmm7nnpn6vn20s30bnsy94qw0000gn/T/fnm-shell-2342283/bin/node]
 8: 0x10023663f v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/var/folders/_c/xmm7nnpn6vn20s30bnsy94qw0000gn/T/fnm-shell-2342283/bin/node]
 9: 0x100235b81 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/var/folders/_c/xmm7nnpn6vn20s30bnsy94qw0000gn/T/fnm-shell-2342283/bin/node]
10: 0x100235220 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/var/folders/_c/xmm7nnpn6vn20s30bnsy94qw0000gn/T/fnm-shell-2342283/bin/node]
11: 0x31d6b1edbe3d 
12: 0x31d6b1e918d5 
13: 0x31d6b1e918d5 
14: 0x31d6b1e918d5 

That new errors is telling you that the better-sqlite3 was built successfully, but its dependency integer (which is also a native module) was not built. Perhaps you should open an issue with fnm, letting them know that their project is not compatible with existing packages because its behavior diverges from the official package manager bundled with Node.js.

@JoshuaWise So it turns out the issue was related to default configuration of new node installations. By default, the config sets to "ignore-scripts = true" for good reasons, so your package install scripts (for better-sqlite3 and integer) are never run.

Unfortunately, it silently _"succeeds"_ (exit status 0) https://github.com/npm/npm/issues/12082, and I only found the issue by running npm install --loglevel verbose and confirming with npm config list. Once I set ignore-scripts to false temporarily, everything worked as expected.

I don't if there's anything that you can change on your end to display a notice, trigger a warning, etc., but if you can't rely on npm scripts to be run on install, maybe it's worthwhile including in the README or at least the troubleshooting guide.

This has been fixed in v7.0.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Silve2611 picture Silve2611  ยท  6Comments

imtbl picture imtbl  ยท  6Comments

horpto picture horpto  ยท  4Comments

pke picture pke  ยท  3Comments

instagendleg picture instagendleg  ยท  4Comments