在 Mac 上安装 better-sqlite3 时出现问题

lar*_*rkx 3 node.js npm-install better-sqlite3 quick.db

我尝试安装它的原因是使用 fast.db 作为默认驱动程序,但我似乎无法弄清楚错误是什么。也许堆栈溢出的好心人能够提供一些帮助。看起来它成功地完成了大部分安装过程,但最终失败了。尝试使用这个新版本的 QuickDB 一直是一种持续的痛苦。

这是控制台生成的日志:

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
Run Code Online (Sandbox Code Playgroud)

Luk*_*uke 9

这听起来很疯狂,但我安装它的唯一方法是确保我的目录路径中没有空格。

“/我的工作/我的应用程序/”->“/我的工作/我的应用程序/”

转到节点 18.5.0 并没有修复它。