node.jsnpm-installquick.dbbetter-sqlite3

Issue installing better-sqlite3 on Mac


The reason I'm trying to install it is to use quick.db as its the default driver however I can't seem to figure out what the error is. Perhaps the kind people of stack overflow will be able to provide some assistance. It seems like it manages to run through most of the install process but fails towards the end. It's just been a non-stop pain trying to use this new version of QuickDB.

This is the log produced by console:

npm ERR! code 1
npm ERR! path /Projects/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || npm run build-release
npm ERR! > better-sqlite3@7.5.3 build-release
npm ERR! > node-gyp rebuild --release
npm ERR! 
npm ERR!   TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR!   ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR! rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR! prebuild-install warn install No prebuilt binaries found (target=16.14.0 runtime=node arch=arm64 libc= platform=darwin)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.14.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.10.2 found at "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3"
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Projects/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   '/Projects/node_modules/better-sqlite3/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Projects/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/[]/Library/Caches/node-gyp/16.14.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=/Users/[]/Library/Caches/node-gyp/16.14.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Projects/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/[]/Library/Caches/node-gyp/16.14.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Projects/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! /bin/sh: Projects/node_modules/better-sqlite3/build/Release/lib.host:/Users/[]/Documents/Coding: No such file or directory
npm ERR! node:internal/fs/utils:344
npm ERR!     throw err;
npm ERR!     ^
npm ERR! 
npm ERR! Error: ENOENT: no such file or directory, copyfile '/Projects/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c' -> '/Projects/node_modules/better-sqlite3/build/Release/obj/gen/sqlite3/sqlite3.c'
npm ERR!     at Object.copyFileSync (node:fs:2802:3)
npm ERR!     at Object.<anonymous> (/Projects/node_modules/better-sqlite3/deps/copy.js:25:5)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1103:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:981:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
npm ERR!     at node:internal/main/run_main_module:17:47 {
npm ERR!   errno: -2,
npm ERR!   syscall: 'copyfile',
npm ERR!   code: 'ENOENT',
npm ERR!   path: '/Projects/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c',
npm ERR!   dest: '/Projects/node_modules/better-sqlite3/build/Release/obj/gen/sqlite3/sqlite3.c'
npm ERR! }
npm ERR! make: *** [ba23eeee118cd63e16015df367567cb043fed872.intermediate] 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 (Projects/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.5.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Projects/node_modules/.bin/node-gyp" "rebuild" "--release"
npm ERR! gyp ERR! cwd /Projects/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/[]/.npm/_logs/2022-06-29T19_21_52_645Z-debug-0.log

Solution

  • This sounds crazy but the only way I could get it to install was to make sure that my directory path had no spaces in it.

    "/my work/my app/" -> "/my-work/my-app/"

    Going to node 18.5.0 didn't fix it.