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

2022 Error: Could not locate the bindings file. #866

Closed
broccolihighkicks opened this issue Aug 20, 2022 · 6 comments
Closed

2022 Error: Could not locate the bindings file. #866

broccolihighkicks opened this issue Aug 20, 2022 · 6 comments

Comments

@broccolihighkicks
Copy link

I get this error after install:

Error: Could not locate the bindings file. Tried:
 → /x/build/better_sqlite3.node
 → /x/build/Debug/better_sqlite3.node
 → /x/build/Release/better_sqlite3.node
 → /x/out/Debug/better_sqlite3.node
 → /x/Debug/better_sqlite3.node
 → /x/out/Release/better_sqlite3.node
 → /x/Release/better_sqlite3.node
 → /x/build/default/better_sqlite3.node
 → /x/compiled/18.7.0/darwin/arm64/better_sqlite3.node
 → /x/addon-build/release/install-root/better_sqlite3.node
 → /x/addon-build/debug/install-root/better_sqlite3.node
 → /x/addon-build/default/install-root/better_sqlite3.node
 → /x/lib/binding/node-v108-darwin-arm64/better_sqlite3.node

I noticed that node-v108-darwin-arm64 is not in the release assets: https://github.com/WiseLibs/better-sqlite3/releases/tag/v7.6.2

Also, the lookup folders above are looking in my projects folder /x/ not /x/node_modules/better-sqlite3/.

Possible fix: ln -s node_modules/better-sqlite3/build ./build seems to avoid this issue.

Can you patch better-sqlite3 to change look up paths to include `/x/node_modules/better-sqlite3/``?

Similar issues from 2018 that are closed.

Versions

Mac M1.
Node v18.7.0.

yarn.lock

better-sqlite3@^7.6.2:
  version "7.6.2"
  resolved "https://registry.yarnpkg.com/better-sqlite3/-/better-sqlite3-7.6.2.tgz#47cd8cad5b9573cace535f950ac321166bc31384"
  integrity sha512-S5zIU1Hink2AH4xPsN0W43T1/AJ5jrPh7Oy07ocuW/AKYYY02GWzz9NH0nbSMn/gw6fDZ5jZ1QsHt1BXAwJ6Lg==
  dependencies:
    bindings "^1.5.0"
    prebuild-install "^7.1.0"

tree node_modules/better-sqlite3/build

node_modules/better-sqlite3/build
├── Makefile
├── Release
│   ├── better_sqlite3.node
│   ├── obj
│   │   └── gen
│   │       └── sqlite3
│   │           ├── sqlite3.c
│   │           ├── sqlite3.h
│   │           └── sqlite3ext.h
│   ├── obj.target
│   │   ├── better_sqlite3
│   │   │   └── src
│   │   │       └── better_sqlite3.o
│   │   ├── deps
│   │   │   └── locate_sqlite3.stamp
│   │   ├── sqlite3
│   │   │   └── gen
│   │   │       └── sqlite3
│   │   │           └── sqlite3.o
│   │   └── test_extension
│   │       └── deps
│   │           └── test_extension.o
│   ├── sqlite3.a
│   └── test_extension.node
├── better_sqlite3.target.mk
├── binding.Makefile
├── config.gypi
├── deps
│   ├── locate_sqlite3.target.mk
│   ├── sqlite3.Makefile
│   └── sqlite3.target.mk
├── gyp-mac-tool
└── test_extension.target.mk

@gamanox
Copy link

gamanox commented Dec 14, 2022

Try installing XCode and open it then run again the npm/yarn install process @broccolihighkicks

@thanhnguyen2187
Copy link

thanhnguyen2187 commented Mar 7, 2023

I ran into this issue on trying to run a file that is the result of esbuild --bundle. A fix for this is to build better-sqlite3 in node_modules first, and then copy the built folder Release to your own build:

cd node_modules/better-sqlite3
npm run build-release
# or `yarn build-release`

# move back to the source folder
cd ..
cd ..

# copy the folder itself
cp -r node_modules/better-sqlite3/build/Release/ build/

@houd1ni
Copy link

houd1ni commented Mar 16, 2023

@JoshuaWise What piece of code tries to find the binding ? What obstacle prevents from patching it to try more in /node_modules prefix ? The hack of @thanhnguyen2187 is way too dirty and seems to be the only option when using esbuild bundler that is the future and somewhere required. At the same time the solution seems to be a "oneliner", but I could not find the code in this repo briefly enough to make a PR. Looking forward to get a bit of help c:

@JoshuaWise
Copy link
Member

@houd1ni The binding is found by the bindings package, which automatically locates the binding for standard installations. If you are using some third-party bundler (like esbuild), it probably won't work, but you can always point to the binding manually by using the nativeBinding option.

@jdspugh
Copy link

jdspugh commented Sep 30, 2023

I ran into this issue on trying to run a file that is the result of esbuild --bundle. A fix for this is to build better-sqlite3 in node_modules first, and then copy the built folder Release to your own build:

cd node_modules/better-sqlite3
npm run build-release
# or `yarn build-release`

# move back to the source folder
cd ..
cd ..

# copy the folder itself
cp -r node_modules/better-sqlite3/build/Release/ build/

For me this worked:

cd node_modules/better-sqlite3
npm run build-release
cd ..

@deadcoder0904
Copy link

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

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

No branches or pull requests

7 participants