WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.26k stars 391 forks source link

better-sqlite3 error on start up on VPS #1085

Closed ScattrdBlade closed 9 months ago

ScattrdBlade commented 9 months ago

Whenever trying to start my bot, I get this error:

/home/container/node_modules/bindings/bindings.js:137
  throw err;
  ^
Error: Could not locate the bindings file. Tried:
 → /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/20.8.0/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-v115-linux-x64/better_sqlite3.node
    at bindings (/home/container/node_modules/bindings/bindings.js:128:9)
    at new Database (/home/container/node_modules/better-sqlite3/lib/database.js:48:64)
    at Database (/home/container/node_modules/better-sqlite3/lib/database.js:11:10)
    at new SqliteDriver (/home/container/node_modules/quick.db/out/drivers/SqliteDriver.js:12:26)
    at new QuickDB (/home/container/node_modules/quick.db/out/index.js:29:28)
    at Object.<anonymous> (/home/container/index.js:8:12)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12) {
  tries: [
    '/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/20.8.0/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-v115-linux-x64/better_sqlite3.node'
  ]
}

This is the error when attempting to install node/npm and better-sqlite3:

[##################] - reify:better-sqlite3: timing reify:audit Completed in 39
[##################] - reify:better-sqlite3: timing reify:audit Completed in 39
[##################] - reify:better-sqlite3: timing reify:audit Completed in 39
[##################] - reify:better-sqlite3: timing reify:audit Completed in 39
[##################] - reify:better-sqlite3: timing reify:audit Completed in 39
[##################] - reify:better-sqlite3: timing reify:audit Completed in 39
[##################] - reify:better-sqlite3: timing reify:audit Completed in 39
[##################] - reify:better-sqlite3: timing reify:audit Completed in 39
npm ERR! code 1
npm ERR!   TOUCH Release/obj.target/deps/locate_sqlite3.stamp
npm ERR!   CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
npm ERR! rm -f Release/obj.target/deps/sqlite3.a Release/obj.target/deps/sqlite3.a.ar-file-list; mkdir -p `dirname Release/obj.target/deps/sqlite3.a`
npm ERR! ar crs Release/obj.target/deps/sqlite3.a @Release/obj.target/deps/sqlite3.a.ar-file-list
npm ERR!   COPY Release/sqlite3.a
npm ERR!   CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
npm ERR! rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR! make: Leaving directory '/home/container/node_modules/better-sqlite3/build'
npm ERR! prebuild-install warn install No prebuilt binaries found (target=20.8.0 runtime=node arch=x64 libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.8.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/container/node_modules/better-sqlite3/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/container/.cache/node-gyp/20.8.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/container/.cache/node-gyp/20.8.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/container/.cache/node-gyp/20.8.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/container/node_modules/better-sqlite3',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ./src/better_sqlite3.lzz:11,
npm ERR!                  from ../src/better_sqlite3.cpp:4:
npm ERR! /home/container/.cache/node-gyp/20.8.0/include/node/node.h:1190:7: warning: cast between incompatible function types from 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>)' to 'node::addon_context_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>, void*)'} [-Wcast-function-type]
npm ERR!  1190 |       (node::addon_context_register_func) (regfunc),                  \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /home/container/.cache/node-gyp/20.8.0/include/node/node.h:1208:3: note: in expansion of macro 'NODE_MODULE_CONTEXT_AWARE_X'
npm ERR!  1208 |   NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
npm ERR!       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /home/container/.cache/node-gyp/20.8.0/include/node/node.h:1239:3: note: in expansion of macro 'NODE_MODULE_CONTEXT_AWARE'
npm ERR!  1239 |   NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME,                     \
npm ERR!       |   ^~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ./src/better_sqlite3.lzz:67:1: note: in expansion of macro 'NODE_MODULE_INIT'
npm ERR! ./src/util/macros.lzz: In function 'void SetPrototypeGetter(v8::Isolate*, v8::Local<v8::External>, v8::Local<v8::FunctionTemplate>, const char*, v8::AccessorGetterCallback)':
npm ERR! ./src/util/macros.lzz:157:21: error: 'v8::AccessorSignature' has not been declared
npm ERR! ./src/util/binder.lzz: In static member function 'static bool Binder::IsPlainObject(v8::Isolate*, v8::Local<v8::Object>)':
npm ERR! ./src/util/binder.lzz:37:51: error: 'class v8::Object' has no member named 'CreationContext'; did you mean 'GetCreationContext'?
npm ERR! ./src/util/data.lzz: In function 'v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_stmt*, int, bool)':
npm ERR! ./src/util/data.lzz:73:92: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR! ./src/util/data.lzz:73:197: note: here
npm ERR! ./src/util/data.lzz: In function 'v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_value*, bool)':
npm ERR! ./src/util/data.lzz:77:81: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR! ./src/util/data.lzz:77:175: note: here
npm ERR! make: *** [better_sqlite3.target.mk:125: Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Linux 5.4.0-164-generic
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd /home/container/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v20.8.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /home/container/.npm/_logs/2023-10-11T16_24_34_873Z-debug-0.log

I've already tried deleting node_modules and package-lock.json and re-installing node/npm, but I still get this error. FYI this only happens on non-local clients like a VPS [the context for the project I'm working on is a Discord bot programmed in discord.js]

ScattrdBlade commented 9 months ago

From what I understand, based on the results of this also happening on my school admin-locked laptop, I believe this has something to do with lack of required elevations on the OS the code is run on. Please do correct me if I'm wrong though.