TryGhost / node-sqlite3

SQLite3 bindings for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while compiling on a Mac M1

lmarcelocc opened this issue · comments

Issue Summary

Environment

MacOS Ventura 13.6.1 with a chip Apple M1.
Node v18.18.2
JAVA 19.0.2 (tried also with 17 and 21)

I've a sample project where everything works fine, with nodejs-cordova, until I add this sqlite3 plugin.

I have this issue:
image

Error log gyp info spawn make gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ] /Users/marcelo/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang -o Release/obj.target/nothing/../node-addon-api/nothing.o ../../node-addon-api/nothing.c '-DNODE_GYP_MODULE_NAME=nothing' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' '-D_GLIBCXX_USE_C99_MATH' -I/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/app/libs/cdvnodejsmobile/libnode/include/node -I/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/app/libs/cdvnodejsmobile/libnode/src -I/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/app/libs/cdvnodejsmobile/libnode/deps/openssl/config -I/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/app/libs/cdvnodejsmobile/libnode/deps/openssl/openssl/include -I/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/app/libs/cdvnodejsmobile/libnode/deps/uv/include -I/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/app/libs/cdvnodejsmobile/libnode/deps/zlib -I/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/app/libs/cdvnodejsmobile/libnode/deps/v8/include -fasm-blocks -mpascal-strings -O3 -gdwarf-2 -arch arm64 -MMD -MF ./Release/.deps/Release/obj.target/nothing/../node-addon-api/nothing.o.d.raw -c rm -f Release/nothing.a && ./gyp-mac-tool filter-libtool libtool -static -o Release/nothing.a Release/obj.target/nothing/../node-addon-api/nothing.o error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/nothing/../node-addon-api/nothing.o is not an object file (not allowed in a library) make: *** [Release/nothing.a] Error 1 gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/Users/marcelo/.nvm/versions/node/v18.18.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23) gyp ERR! stack at ChildProcess.emit (node:events:517:28) gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:292:12) gyp ERR! System Darwin 22.6.0 gyp ERR! command "/Users/marcelo/.nvm/versions/node/v18.18.2/bin/node" "/Users/marcelo/.nvm/versions/node/v18.18.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3/lib/binding/napi-v6-platform-libc-arch/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3/lib/binding/napi-v6-platform-libc-arch" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=6" "--node_napi_label=napi-v6" gyp ERR! cwd /Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3 gyp ERR! node -v v18.18.2 gyp ERR! node-gyp -v v9.4.0 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/Users/marcelo/.nvm/versions/node/v18.18.2/bin/node /Users/marcelo/.nvm/versions/node/v18.18.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3/lib/binding/napi-v6-platform-libc-arch/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3/lib/binding/napi-v6-platform-libc-arch --napi_version=9 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1) node-pre-gyp ERR! stack at ChildProcess. (/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23) Failed to execute '/Users/marcelo/.nvm/versions/node/v18.18.2/bin/node /Users/marcelo/.nvm/versions/node/v18.18.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3/lib/binding/napi-v6-platform-libc-arch/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3/lib/binding/napi-v6-platform-libc-arch --napi_version=9 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1) node-pre-gyp ERR! stack at ChildProcess.emit (node:events:517:28) node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1098:16) node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:303:5) node-pre-gyp ERR! System Darwin 22.6.0 node-pre-gyp ERR! command "/Users/marcelo/.nvm/versions/node/v18.18.2/bin/node" "/Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3 node-pre-gyp ERR! node -v v18.18.2 node-pre-gyp ERR! node-pre-gyp -v v1.0.11 node-pre-gyp ERR! not ok npm info run sqlite3@5.1.6 install { code: 1, signal: null } npm verb stack Error: command failed npm verb stack at ChildProcess. (/Users/marcelo/.nvm/versions/node/v18.18.2/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27) npm verb stack at ChildProcess.emit (node:events:517:28) npm verb stack at maybeClose (node:internal/child_process:1098:16) npm verb stack at ChildProcess._handle.onexit (node:internal/child_process:303:5) npm verb pkgid sqlite3@5.1.6 npm verb cwd /Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project npm verb Darwin 22.6.0 npm verb node v18.18.2 npm verb npm v9.8.1 npm ERR! code 1 npm ERR! path /Users/marcelo/Documents/Projects/gmmCordova12/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/sqlite3 npm ERR! command failed npm ERR! command sh -c node-pre-gyp install --fallback-to-build npm verb exit 1 npm verb unfinished npm timer build 1700149733618 npm verb unfinished npm timer build:deps 1700149733618 npm verb unfinished npm timer build:run:install 1700149733622 npm verb unfinished npm timer build:run:install:node_modules/sqlite3 1700149733622 npm verb code 1

From what I understood, since version 5.1.1 we shouldn't need to build cause ARM64 binaries are being provided, but it seems that's not happening on my case.

Any hint ?

Thanks in advance

Steps to Reproduce

One of two:
1)

  • Just create a cordova 12 project
  • Add cordova-nodejs-plugin
  • Everything seems to work fine with cordova-nodejs-plugin plugin
  • Add sqlite3 plugin to nodejs project
  • Do an ionic cordova build android
  • Error appear

Clone this repo:

Version

5.1.6

Node.js Version

v18.18.2

How did you install the library?

npm i sqlite3 and also tried with npm i sqlite3 --build-from-source --target_arch=arm64

There is no binaries for apple silicon due to a bug in prebuild, see #1641 (comment)

Could we repurpose this issue to be about switching to prebuildify?