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

Impossible to install sqlite-3 in Mac M1 MacOS 12.1 #1538

Closed
aminta opened this issue Dec 31, 2021 · 36 comments
Closed

Impossible to install sqlite-3 in Mac M1 MacOS 12.1 #1538

aminta opened this issue Dec 31, 2021 · 36 comments

Comments

@aminta
Copy link

aminta commented Dec 31, 2021

Hello, I've tried with several versions of Node (12.x, 14.x, 16.x) to successful install sqlite-3 with npm install sqlite3 but no way, I get always the same error. The dependency in package.json is "sqlite3": "5.0.2"

Here's the error generated by node v14.17.3:

error /Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments: 
Directory: /Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | arm64
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp info check checked for "/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node" (not found)
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz 
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info ok 
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.8.9 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/Users/me/.nvm/versions/node/v14.17.3/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/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/me/.nvm/versions/node/v14.17.3/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/me/Library/Caches/node-gyp/14.17.3/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/me/Library/Caches/node-gyp/14.17.3',
gyp info spawn args   '-Dnode_gyp_dir=/Users/me/.nvm/versions/node/v14.17.3/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/me/Library/Caches/node-gyp/14.17.3/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/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 ok 
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
  LIBTOOL-STATIC Release/nothing.a
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c
/bin/sh: App/strapi/psrstrapi4/node_modules/sqlite3/build/Release/lib.host:/Users/me/Sviluppo/App/Psr: No such file or directory
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3340000/sqlite3.o
Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c:744:17: warning: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Wstring-concatenation]
  "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
                ^
               ,
Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c:56:27: note: expanded from macro 'CTIMEOPT_VAL'
#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
                          ^
Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c:55:28: note: expanded from macro 'CTIMEOPT_VAL_'
#define CTIMEOPT_VAL_(opt) #opt
                           ^
<scratch space>:5:1: note: expanded from here
"1"
^
Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c:744:3: note: place parentheses around the string literal to silence warning
  "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
  ^
1 warning generated.
  LIBTOOL-STATIC Release/sqlite3.a
  CXX(target) Release/obj.target/node_sqlite3/src/backup.o
clang: error: no such file or directory: 'App/strapi/psrstrapi4/node_modules/node-addon-api'
make: *** [Release/obj.target/node_sqlite3/src/backup.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/me/.nvm/versions/node/v14.17.3/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:375:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 21.2.0
gyp ERR! command "/Users/me/.nvm/versions/node/v14.17.3/bin/node" "/Users/me/.nvm/versions/node/v14.17.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
gyp ERR! cwd /Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3
gyp ERR! node -v v14.17.3
gyp ERR! node-gyp -v v8.4.1
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/Users/me/.nvm/versions/node/v14.17.3/bin/node /Users/me/.nvm/versions/node/v14.17.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:375:28)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Darwin 21.2.0
node-pre-gyp ERR! command "/Users/me/.nvm/versions/node/v14.17.3/bin/node" "/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3
node-pre-gyp ERR! node -v v14.17.3
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/Users/me/.nvm/versions/node/v14.17.3/bin/node /Users/me/.nvm/versions/node/v14.17.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/me/Sviluppo/App/My App/strapi/psrstrapi4/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
@aminta
Copy link
Author

aminta commented Dec 31, 2021

Ok, it seems incredible but the problem was... the directory name ("My app") with spaces!

@sasiacob
Copy link

Same problem. And I don't have spaces in my directory app.

@Piumal1999
Copy link

Piumal1999 commented Jan 15, 2022

This happened to me as well. My app directory was /Users/piumal1999/My Files/TestApp and it always threw that 403 error when I was trying to install sqlite3. Then I just moved it to another directory that didn't contain any spaces in the path (/Users/piumal1999/testdir/TestApp). Then it worked well. Very Unusual behaviour.🤷‍♂️🤷‍♂️🤷‍♂️

Thanks for the idea @aminta @sasiacob

@marmos91
Copy link

Same problem, and I don't have spaces in my directory as well...

@GvadimI
Copy link

GvadimI commented Jan 28, 2022

I have same problem too, and my directory path without spaces as well.

@marcin-zajac
Copy link

same problem on my M1...

@tcarrio
Copy link

tcarrio commented Feb 10, 2022

This issue still occurs. Encountering the 403 access denied error when trying to retrieve the precompiled bundle from S3.

@tcarrio
Copy link

tcarrio commented Feb 10, 2022

As a short follow-up: sqlite mentions there is no support for Node 16.x. It is worth checking if this is what you are running when you run into this issue. If you are hitting a 403 error and can't build, you probably have homebrew overriding your path for libtool or other tooling for compiling the SQLite3 module.

If you happen to be someone who

  1. Gets a 403 on pulling the module in node-pre-gyp
  2. Gets a compiler error when building the sqlite3 module

You just might want to check your $PATH and verify you aren't overriding one of the build tools.

@marcin-zajac
Copy link

If you use yarn to install packages, you may use npm, for me it works in this case.

@danielehrhardt
Copy link

danielehrhardt commented Feb 11, 2022

As a short follow-up: sqlite mentions there is no support for Node 16.x. It is worth checking if this is what you are running when you run into this issue. If you are hitting a 403 error and can't build, you probably have homebrew overriding your path for libtool or other tooling for compiling the SQLite3 module.

If you happen to be someone who

  1. Gets a 403 on pulling the module in node-pre-gyp
  2. Gets a compiler error when building the sqlite3 module

You just might want to check your $PATH and verify you aren't overriding one of the build tools.

How should the Path look like?


npm ERR! code 1
npm ERR! path /Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
npm ERR!   LIBTOOL-STATIC Release/nothing.a
npm ERR!   ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c
npm ERR! Failed to execute '/Users/danielehrhardt/.nvm/versions/node/v14.18.2/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | darwin | arm64
npm ERR! node-pre-gyp WARN Using request for node-pre-gyp https download
npm ERR! node-pre-gyp info check checked for "/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node" (not found)
npm ERR! node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
npm ERR! node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
npm ERR! node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.10 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/homebrew/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   '/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/danielehrhardt/Library/Caches/node-gyp/14.18.2/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/danielehrhardt/Library/Caches/node-gyp/14.18.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/danielehrhardt/Library/Caches/node-gyp/14.18.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/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 ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
npm ERR! /bin/sh: python: command not found
npm ERR! make: *** [Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c] Error 127
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 (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
npm ERR! gyp ERR! System Darwin 21.4.0
npm ERR! gyp ERR! command "/Users/danielehrhardt/.nvm/versions/node/v14.18.2/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd /Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3
npm ERR! gyp ERR! node -v v14.18.2
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/Users/danielehrhardt/.nvm/versions/node/v14.18.2/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1058:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.4.0
npm ERR! node-pre-gyp ERR! command "/Users/danielehrhardt/.nvm/versions/node/v14.18.2/bin/node" "/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3
npm ERR! node-pre-gyp ERR! node -v v14.18.2
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.11.0
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/danielehrhardt/.npm/_logs/2022-02-11T20_02_13_996Z-debug.log

@danielehrhardt
Copy link

danielehrhardt commented Feb 11, 2022

As a short follow-up: sqlite mentions there is no support for Node 16.x. It is worth checking if this is what you are running when you run into this issue. If you are hitting a 403 error and can't build, you probably have homebrew overriding your path for libtool or other tooling for compiling the SQLite3 module.
If you happen to be someone who

  1. Gets a 403 on pulling the module in node-pre-gyp
  2. Gets a compiler error when building the sqlite3 module

You just might want to check your $PATH and verify you aren't overriding one of the build tools.

How should the Path look like?


npm ERR! code 1
npm ERR! path /Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
npm ERR!   LIBTOOL-STATIC Release/nothing.a
npm ERR!   ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c
npm ERR! Failed to execute '/Users/danielehrhardt/.nvm/versions/node/v14.18.2/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | darwin | arm64
npm ERR! node-pre-gyp WARN Using request for node-pre-gyp https download
npm ERR! node-pre-gyp info check checked for "/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node" (not found)
npm ERR! node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
npm ERR! node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
npm ERR! node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-darwin-arm64.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.10 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/homebrew/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   '/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/danielehrhardt/Library/Caches/node-gyp/14.18.2/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/danielehrhardt/Library/Caches/node-gyp/14.18.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/danielehrhardt/Library/Caches/node-gyp/14.18.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/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 ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
npm ERR! /bin/sh: python: command not found
npm ERR! make: *** [Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c] Error 127
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 (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
npm ERR! gyp ERR! System Darwin 21.4.0
npm ERR! gyp ERR! command "/Users/danielehrhardt/.nvm/versions/node/v14.18.2/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd /Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3
npm ERR! gyp ERR! node -v v14.18.2
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/Users/danielehrhardt/.nvm/versions/node/v14.18.2/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1058:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.4.0
npm ERR! node-pre-gyp ERR! command "/Users/danielehrhardt/.nvm/versions/node/v14.18.2/bin/node" "/Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/danielehrhardt/projects/podcastbusiness/podcastbusinessapi/node_modules/sqlite3
npm ERR! node-pre-gyp ERR! node -v v14.18.2
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.11.0
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/danielehrhardt/.npm/_logs/2022-02-11T20_02_13_996Z-debug.log

If you want to use sqlite3 with a M1 / M1 Pro / M1 Max do the following:

  1. Start a Terminal using Rosetta
  2. Verify with arch it should be i386
  3. nvm install lts/fermium
  4. nvm use lts/fermium
  5. node -e 'console.log(process.arch)' it should be x64
  6. nvm alias intel lts/fermium
  7. nvm use intel this you can used in the project
  8. Navigate to the project
  9. rm -rf node_modules
    10 npm install

@reorx
Copy link

reorx commented Feb 13, 2022

If you are using:

  • macOS: 12.1 Monterey
  • chip: Apple M1
  • node version: v16.13.0

Then you can try the following:

# 1. Install sqlite3 with homebrew
brew install sqlite3

# 2. export compiler related env variables
export LDFLAGS="-L/opt/homebrew/opt/sqlite/lib"
export CPPFLAGS="-I/opt/homebrew/opt/sqlite/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/sqlite/lib/pkgconfig"

# 3. prepare for a fresh install
rm -rf node_modules
npm cache verify

# 4. use npm instead of yarn
npm i sqlite3
Thank you. 操你妈的狗 node-gyp

@fedu
Copy link

fedu commented Feb 25, 2022

+1

@PsclDev
Copy link

PsclDev commented Apr 3, 2022

None of the Answered helped so far for me, has Anyone something new found out?

@jonguenther
Copy link

None of the Answered helped so far for me, has Anyone something new found out?

For me it worked when going back to Node 14 (v.14.19.1) using nvm.

@visoft
Copy link

visoft commented Apr 4, 2022

This comment worked to help me install sqllite3 #1413 (comment) on my M1 MacBook Pro with node v16.13.0

@jwilsonimply
Copy link

+1

@daniellockyer
Copy link
Member

Would you be able to try with sqlite3 v5.0.3? 🙂

@qiuzhanghua
Copy link

[email protected] success!

https://qiuzhanghua.github.io/posts/2022/0628-01-sqlite3-nodejs-m1/

@jonguenther
Copy link

[email protected] works now with node v16 (tested with v16.14.2) 🥳

P.S.: I did not need to do any additional changes suggested by @qiuzhanghua except for installing sqlite using brew

@evantahler
Copy link

For me, npm config set python python3 was the solution

@christopher-caldwell
Copy link

For me, npm config set python python3 was the solution

I get a syntax error when doing this:

gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/bin/python3 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                       ^
gyp ERR! stack SyntaxError: invalid syntax

@zeallat
Copy link

zeallat commented Aug 20, 2022

This comment worked to help me install sqllite3 #1413 (comment) on my M1 MacBook Pro with node v16.13.0

@visoft This looks seamless solution to me. Huge thanks!

@RMcDOttawa
Copy link

Ok, it seems incredible but the problem was... the directory name ("My app") with spaces!

This fixed it for me. Not just a space in the containing directory - but no spaces anywhere in the complete path leading to the directory. Removing this spaces, everything worked. Thanks!

@eireausman
Copy link

Ok, it seems incredible but the problem was... the directory name ("My app") with spaces!

Thanks for this! Issue solved for me.

@daniellockyer
Copy link
Member

FYI v5.1.1 now comes with prebuilt Darwin ARM64 binaries 🙂 https://github.com/TryGhost/node-sqlite3/releases/tag/v5.1.1

@ozziedev
Copy link

For me, npm config set python python3 was the solution

This was the solution for me. Don't think the issue is M1 related at all.

@tcarrio
Copy link

tcarrio commented Jan 29, 2023

For me, npm config set python python3 was the solution

This was the solution for me. Don't think the issue is M1 related at all.

The issue is related to the M1 since when there isn't a precompiled binary release available it need to compile it from source locally, and the default build environment on macOS cannot compile node-sqlite3 without the additional configuration you've noted.

But now that there is a binary release for arm64-darwin as of 5.1.1, you should not need to configure Python anymore 😁

@hraban
Copy link

hraban commented Mar 23, 2023

As a short follow-up: sqlite mentions there is no support for Node 16.x. It is worth checking if this is what you are running when you run into this issue. If you are hitting a 403 error and can't build, you probably have homebrew overriding your path for libtool or other tooling for compiling the SQLite3 module.

If you happen to be someone who

1. Gets a 403 on pulling the module in `node-pre-gyp`

2. Gets a compiler error when building the `sqlite3` module

You just might want to check your $PATH and verify you aren't overriding one of the build tools.

This was the case for me: I have a real GCC as my g++ binary, earlier in my PATH than Mac's default /usr/bin/g++ (which is just a symlink to clang). This was causing the build to fail. Solution:

PATH="/usr/bin:$PATH" npm ci

@liarco
Copy link

liarco commented Mar 24, 2023

Just had the same issue but no M1 (Intel i9) and I was on macOS Catalina.

I'll leave my solution here as reference:
I installed NodeJS using brew and I usually use Yarn instead of NPM, that's why I never noticed that by jumping between node versions, my node installation got corrupted and npm was not linked anymore (running npm on a terminal resulted in npm: command not found). The build error doesn't say it explicitly, but that's exactly the error it runs into while compiling (I had to run the build steps manually to figure it out).

Running brew postinstall node fixed the broken nodejs and then everything worked fine.

I hope this helps.

@songtang0
Copy link

I solved this problem by setting the node version to 12.22.0 and then using the 'yarn' command.

@captbilard
Copy link

For me, npm config set python python3 was the solution

This also worked for me, I had also tried installing sqlite using brew initially, but the error still popped up. Probably a combination of both or just this, regardless though it's working.

@AdamGerthel
Copy link

For me, npm config set python python3 was the solution

This was the solution for me. Don't think the issue is M1 related at all.

This worked for me too - but why?

@captbilard
Copy link

For me, npm config set python python3 was the solution

This was the solution for me. Don't think the issue is M1 related at all.

This worked for me too - but why?

We basically just telling npm to use python3 when trying to install packages that may have Python dependencies and they call the key python.

@cinjon
Copy link

cinjon commented Nov 8, 2023

I am running into this issue still. I'm using bun to install sqlite3 but I don't think that should make a difference. I'm getting the error Cannot find module '<path>/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node'

I also tried the python set but got python is not a valid npm option.

@byCedric
Copy link

For the people using Bun and running into the error below.

Cannot find module '/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node'

Bun doesn't run package lifecycle scripts by default, as it's considered a security issue. In order to run the lifecycle scripts for sqlite3, you need to add the "trustedDependencies": ["sqlite3"] to your package.json (docs)

After changing this, you'll need to regenerate the lockfile of Bun.

  • rm -rf node_modules bun.lockb
  • bun install

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests