Search code examples
macosnode-gypdarwinmacos-venturabetter-sqlite3

Cannot install better-sqlite3 package on MacOS Ventura


I am trying to install the Node.js package better-sqlite3 on my Strapi App, on my new laptop, a MacBook Pro M2 running on MacOS Ventura 13.2.1. It is not successful because, from what I understood, there are packages missing, and specifically while running the make command during the build process of node-gyp (I don't think it is specific for my laptop, because I have seen other people in the same case on Internet, but without a good solution).

I tried to install Xcode but it didn't change anything.
I tried to install autoconf, automake, libtool, pkg-config with brew (because I have seen it was maybe the equivalent of build-tools of Linux on MacOS), but same result.
I also tried to execute xcode-select --install, but was already installed.

I lastly tried on my former laptop - which is a MacBook Pro Intel, running on MacOS Monterey 12.5, it is working perfectly (which is proving thus that it is an error occurring only on the new version)

Here is the error printed on the terminal :

error /Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild --release
Arguments: 
Directory: /Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3
Output:
prebuild-install warn install No prebuilt binaries found (target=16.15.1 runtime=node arch=arm64 libc= platform=darwin)
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info find Python using Python version 3.9.0 found at "/Library/Frameworks/Python.framework/Versions/3.9/bin/python3"
gyp info spawn /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
gyp info spawn args [
gyp info spawn args   '/usr/local/lib/node_modules/npm/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/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Maxime/Library/Caches/node-gyp/16.15.1/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/Maxime/Library/Caches/node-gyp/16.15.1',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/Maxime/Library/Caches/node-gyp/16.15.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/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
/bin/sh: de: command not found
node:internal/fs/utils:345
    throw err;
    ^

Error: ENOENT: no such file or directory, copyfile '/Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c' -> '/Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3/build/Release/obj/gen/sqlite3/sqlite3.c'
    at Object.copyFileSync (node:fs:2817:3)
    at Object.<anonymous> (/Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3/deps/copy.js:25:5)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -2,
  syscall: 'copyfile',
  code: 'ENOENT',
  path: '/Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c',
  dest: '/Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3/build/Release/obj/gen/sqlite3/sqlite3.c'
}
make: *** [ba23eeee118cd63e16015df367567cb043fed872.intermediate] Error 1
rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 22.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3

Thank you very much for your help.


Solution

  • Oh, Sorry! it was just a stupid bug : I had a folder with spaces in the name, and this caused to create a false path to /Users/Maxime/Desktop/Projets de code/mh-info.fr/backend/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c