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

Missing better-sqlite3 binaries break NPM package installation #89

Closed
6 tasks done
aheissenberger opened this issue Dec 6, 2024 · 2 comments
Closed
6 tasks done

Comments

@aheissenberger
Copy link
Contributor

Describe the bug

I checked out the source code and tried to install the packages with pnpm install and fail to install better-sqlite3 on a system with NodeJs Version 23.x and arm. There is the missing precompiled binary for my platform and better-sqlite3 has not been adapted to the V8 api changes in Node 23.

This is not a problem of react-server but I suggest to change the example to one of this options: only use an array as a database, use the unstorage library with a filesystem based adapter or move the library in package.json from dependencies to optionalDependencies and add a README.md to install the missing dependencies or write a a wrapper which uses the built in node:sqlite when available (currently in Node v23 behind a flag) or informs the user to install better-sqlite3. Or create a repository for examples which need platform specific binaries.

I can provide a pull request if you tell me what solution you prefer.

pnpm i
Scope: all 18 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +1753
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1753, reused 1740, downloaded 0, added 6, done
node_modules/.pnpm/@swc+core@1.6.6_@swc+helpers@0.5.5/node_modules/@swc/core: Running postinstall script, done in 62ms
node_modules/.pnpm/@vercel+speed-insights@1.0.12_next@14.2.8_@babel+core@7.24.7_react-dom@19.0.0-rc-3208e73e-202_nfchefvudj6vblueo5cjxpghwi/node_modules/@vercel/speed-insights: Running postinstall script, done in 43ms
node_modules/.pnpm/better-sqlite3@10.1.0/node_modules/better-sqlite3: Running install script, failed in 22.9s
.../node_modules/better-sqlite3 install$ prebuild-install || node-gyp rebuild --release
│ prebuild-install warn install No prebuilt binaries found (target=23.3.0 runtime=node arch=arm64 libc= platform=darwin)
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@10.2.0
│ gyp info using node@23.3.0 | darwin | arm64
│ gyp info find Python using Python version 3.13.0 found at "/opt/homebrew/opt/python@3.13/bin/python3.13"
│ gyp info spawn /opt/homebrew/opt/python@3.13/bin/python3.13
│ gyp info spawn args [
│ gyp info spawn args '/opt/homebrew/Cellar/pnpm/9.14.4/libexec/lib/node_modules/pnpm/dist/node_modules/node-gyp/gyp/gyp_main.py',
│ gyp info spawn args 'binding.gyp',
│ gyp info spawn args '-f',
│ gyp info spawn args 'make',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/ah/SVN-Checkouts/DEV/react-server/react-server/node_modules/.pnpm/better-sqlite3@10.1.0/node_modules/better-sqlite3/build/config.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/opt/homebrew/Cellar/pnpm/9.14.4/libexec/lib/node_modules/pnpm/dist/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/ah/Library/Caches/node-gyp/23.3.0/include/node/common.gypi',
│ gyp info spawn args '-Dlibrary=shared_library',
│ gyp info spawn args '-Dvisibility=default',
│ gyp info spawn args '-Dnode_root_dir=/Users/ah/Library/Caches/node-gyp/23.3.0',
│ gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/Cellar/pnpm/9.14.4/libexec/lib/node_modules/pnpm/dist/node_modules/node-gyp',
│ gyp info spawn args '-Dnode_lib_file=/Users/ah/Library/Caches/node-gyp/23.3.0/<(target_arch)/node.lib',
│ gyp info spawn args '-Dmodule_root_dir=/Users/ah/SVN-Checkouts/DEV/react-server/react-server/node_modules/.pnpm/better-sqlite3@10.1.0/node_modules/better-sqlite3',
│ gyp info spawn args '-Dnode_engine=v8',
│ gyp info spawn args '--depth=.',
│ gyp info spawn args '--no-parallel',
│ gyp info spawn args '--generator-output',
│ gyp info spawn args 'build',
│ gyp info spawn args '-Goutput_dir=.'
│ gyp info spawn args ]
│ gyp info spawn make
│ gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
│   TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
│   ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
│   TOUCH Release/obj.target/deps/locate_sqlite3.stamp
│   CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
│   LIBTOOL-STATIC Release/sqlite3.a
│   CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
│ In file included from ../src/better_sqlite3.cpp:4:
│ In file included from ./src/better_sqlite3.lzz:11:
│ In file included from /Users/ah/Library/Caches/node-gyp/23.3.0/include/node/node.h:73:
│ In file included from /Users/ah/Library/Caches/node-gyp/23.3.0/include/node/v8.h:23:
│ In file included from /Users/ah/Library/Caches/node-gyp/23.3.0/include/node/cppgc/common.h:8:
│ /Users/ah/Library/Caches/node-gyp/23.3.0/include/node/v8config.h:13:2: error: "C++20 or later required."
│    13 | #error "C++20 or later required."|  ^
│ In file included from ../src/better_sqlite3.cpp:4:
│ ./src/util/macros.lzz:31:69: error: no template named 'CopyablePersistentTraits' in namespace 'v8'; did you mean 'NonCopyablePersistentTraits'?
│    31 | template <class T> using CopyablePersistent = v8::Persistent<T, v8::CopyablePersistentTraits<T>>;|                                                                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
│       |                                                                     NonCopyablePersistentTraits
│ /Users/ah/Library/Caches/node-gyp/23.3.0/include/node/v8-persistent-handle.h:223:7: note: 'NonCopyablePersistentTraits' declared here
│   223 | class NonCopyablePersistentTraits {
│       |       ^
│ In file included from ../src/better_sqlite3.cpp:4:
│ ./src/util/macros.lzz:149:6: error: no type named 'AccessorGetterCallback' in namespace 'v8'; did you mean 'AccessorNameGetterCallback'?
│   149 |         v8::AccessorGetterCallback func
│       |         ~~~~^~~~~~~~~~~~~~~~~~~~~~
│       |             AccessorNameGetterCallback
│ /Users/ah/Library/Caches/node-gyp/23.3.0/include/node/v8-object.h:155:7: note: 'AccessorNameGetterCallback' declared here
│   155 | using AccessorNameGetterCallback =
│       |       ^
│ ./src/util/macros.lzz:158:6: error: no type named 'AccessorGetterCallback' in namespace 'v8'; did you mean 'AccessorNameGetterCallback'?
│   158 |         v8::AccessorGetterCallback func
│       |         ~~~~^~~~~~~~~~~~~~~~~~~~~~
│       |             AccessorNameGetterCallback
│ /Users/ah/Library/Caches/node-gyp/23.3.0/include/node/v8-object.h:155:7: note: 'AccessorNameGetterCallback' declared here
│   155 | using AccessorNameGetterCallback =
│       |       ^
│ ./src/util/macros.lzz:172:28: error: no member named 'SetAccessor' in 'v8::ObjectTemplate'
│   172 |         recv->InstanceTemplate()->SetAccessor(
│       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^
│ ./src/objects/database.lzz:17:17: error: no matching function for call to 'SetPrototypeGetter'
│    17 |                 SetPrototypeGetter(isolate, data, t, "open", JS_open);|                 ^~~~~~~~~~~~~~~~~~
│ ./src/util/macros.lzz:153:6: note: candidate function not viable: no known conversion from 'void (v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &)' to 'v8::AccessorNameGetterCallback' (aka 'void (*)(Local<Name>, const Propert…
│   153 | void SetPrototypeGetter(
│       |      ^
│   154 |         v8::Isolate* isolate,
│   155 |         v8::Local<v8::External> data,
│   156 |         v8::Local<v8::FunctionTemplate> recv,
│   157 |         const char* name,
│   158 |         v8::AccessorGetterCallback func
│       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│ ./src/objects/database.lzz:18:17: error: no matching function for call to 'SetPrototypeGetter'
│    18 |                 SetPrototypeGetter(isolate, data, t, "inTransaction", JS_inTransaction);
│       |                 ^~~~~~~~~~~~~~~~~~
│ ./src/util/macros.lzz:153:6: note: candidate function not viable: no known conversion from 'void (v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &)' to 'v8::AccessorNameGetterCallback' (aka 'void (*)(Local<Name>, const Propert…
│   153 | void SetPrototypeGetter(
│       |      ^
│   154 |         v8::Isolate* isolate,
│   155 |         v8::Local<v8::External> data,
│   156 |         v8::Local<v8::FunctionTemplate> recv,
│   157 |         const char* name,
│   158 |         v8::AccessorGetterCallback func
│       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│ ./src/objects/database.lzz:180:21: warning: variable 'status' set but not used [-Wunused-but-set-variable]
│   180 |                 int status = sqlite3_db_config(db_handle, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, NULL);|                     ^
│ ./src/objects/statement.lzz:16:17: error: no matching function for call to 'SetPrototypeGetter'
│    16 |                 SetPrototypeGetter(isolate, data, t, "busy", JS_busy);|                 ^~~~~~~~~~~~~~~~~~
│ ./src/util/macros.lzz:153:6: note: candidate function not viable: no known conversion from 'void (v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &)' to 'v8::AccessorNameGetterCallback' (aka 'void (*)(Local<Name>, const Propert…
│   153 | void SetPrototypeGetter(
│       |      ^
│   154 |         v8::Isolate* isolate,
│   155 |         v8::Local<v8::External> data,
│   156 |         v8::Local<v8::FunctionTemplate> recv,
│   157 |         const char* name,
│   158 |         v8::AccessorGetterCallback func
│       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│ ./src/util/custom-table.lzz:45:9: warning: missing field 'xIntegrity' initializer [-Wmissing-field-initializers]
│    45 |         };
│       |         ^
│ ./src/util/custom-table.lzz:72:9: warning: missing field 'xIntegrity' initializer [-Wmissing-field-initializers]
│    72 |         };
│       |         ^
│ 3 warnings and 8 errors generated.
│ make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1
│ rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
│ gyp ERR! build error 
│ gyp ERR! stack Error: `make` failed with exit code: 2
│ gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/Cellar/pnpm/9.14.4/libexec/lib/node_modules/pnpm/dist/node_modules/node-gyp/lib/build.js:216:23)
│ gyp ERR! System Darwin 24.1.0
│ gyp ERR! command "/opt/homebrew/Cellar/node/23.3.0/bin/node" "/opt/homebrew/Cellar/pnpm/9.14.4/libexec/lib/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
│ gyp ERR! cwd /Users/ah/SVN-Checkouts/DEV/react-server/react-server/node_modules/.pnpm/better-sqlite3@10.1.0/node_modules/better-sqlite3
│ gyp ERR! node -v v23.3.0
│ gyp ERR! node-gyp -v v10.2.0
│ gyp ERR! not ok 
└─ Failed in 22.9s at /Users/ah/SVN-Checkouts/DEV/react-server/react-server/node_modules/.pnpm/better-sqlite3@10.1.0/node_modules/better-sqlite3
node_modules/.pnpm/esbuild@0.21.3/node_modules/esbuild: Running postinstall script, done in 120ms
 ELIFECYCLE  Command failed with exit code 1.

Reproduction

https://github.com/lazarv/react-server

Steps to reproduce

git clone git@github.com:lazarv/react-server.git
cd react-server
pnpm install

System Info

System:
    OS: macOS 15.1.1
    CPU: (12) arm64 Apple M4 Pro
    Memory: 4.40 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.3.0 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - /opt/homebrew/bin/npm
    pnpm: 9.14.4 - /opt/homebrew/bin/pnpm
    bun: 1.1.38 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 131.0.6778.109
    Safari: 18.1.1
    Safari Technology Preview: 18.2
  npmPackages:
    @lazarv/react-server: link:packages/react-server => 0.0.0

Used Package Manager

pnpm

Logs

No response

Validations

@aheissenberger aheissenberger added the pending triage Pending triage label Dec 6, 2024
@lazarv
Copy link
Owner

lazarv commented Dec 6, 2024

I like the unstorage option, although it was a good test case to use a native Node.js dependency for testing module resolution.

For now, I just upgraded better-sqlite3 to version 11.6 which is compatible with Node.js 23.x

With unstorage it would be nice to use different drivers in dev and a production build, so an example like this could be deployed on Vercel using Vercel KV while using file storage in dev.

@lazarv lazarv removed the pending triage Pending triage label Dec 14, 2024
Copy link

This issue has been locked since it has been closed for more than 30 days.

If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest version of @lazarv/react-server. If you have any other comments you should create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants