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

Build fails with "error use of undeclared identifier napi_get_instance_data" #1423

Closed
Almad opened this issue Jan 11, 2021 · 2 comments
Closed

Comments

@Almad
Copy link

Almad commented Jan 11, 2021

I am trying to install SQLite on Mac from source (since I intend to use it for Electron). This fails with napi errors (see attached debug log).

I am using Rosetta on M1 Mac, trying to build an x86 version. I use SQLite3 install from Homebrew and tried various configurations, last of which installs sqlite without error, but also without binding. Hence, running npm install with electron-builder install-app-deps results in the error log below.

Electron installed is the 8.5.5 since it's deemed as the last one supported by this project.

Installation sequence:

  • brew install sqlite sqlcipher
  • npm i napi
  • export LDFLAGS="-Lbrew --prefix/opt/sqlcipher/lib"
  • export CPPFLAGS="-Ibrew --prefix/opt/sqlcipher/include"
  • npm install sqlite3 --runtime=electron --target=1.7.6 --dist-url=https://electronjs.org/headers --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix`
  • npm i

Error log:

almad@hyuga mytestproject % npm i

> [email protected] postinstall
> electron-builder install-app-deps

  • electron-builder  version=22.9.1
  • loaded configuration  file=package.json ("build" field)
  • rebuilding native dependencies  [email protected], [email protected], [email protected] platform=darwin arch=x64
  • install prebuilt binary  name=sharp version=0.26.2 platform=darwin arch=x64
  • build native dependency from sources  name=sharp
                                          version=0.26.2
                                          platform=darwin
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.6
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for cached prebuild @ /Users/almad/.npm/_prebuilds/c9d9b5-sharp-v0.26.2-electron-v76-darwin-x64.tar.gz
    prebuild-install http request GET https://github.com/lovell/sharp/releases/download/v0.26.2/sharp-v0.26.2-electron-v76-darwin-x64.tar.gz
    prebuild-install http 404 https://github.com/lovell/sharp/releases/download/v0.26.2/sharp-v0.26.2-electron-v76-darwin-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=8.5.5 runtime=electron arch=x64 libc= platform=darwin)

  ⨯ cannot execute  cause=exit status 1
                    errorOut=npm ERR! code 1
    npm ERR! path /Users/almad/Documents/projects/mytestproject/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-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-3320300/sqlite3.c
    npm ERR!   TOUCH Release/obj.target/deps/action_before_build.stamp
    npm ERR!   CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3320300/sqlite3.o
    npm ERR!   LIBTOOL-STATIC Release/sqlite3.a
    npm ERR!   CXX(target) Release/obj.target/node_sqlite3/src/backup.o
    npm ERR! Failed to execute '/usr/local/Cellar/node/15.3.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/almad/Documents/projects/mytestproject/node_modules/sqlite3/lib/binding/napi-v6-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/almad/Documents/projects/mytestproject/node_modules/sqlite3/lib/binding/napi-v6-darwin-x64 --napi_version=7 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (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 | x64
    npm ERR! node-pre-gyp WARN Using request for node-pre-gyp https download
    npm ERR! node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.1/napi-v6-darwin-x64.tar.gz
    npm ERR! node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.1/napi-v6-darwin-x64.tar.gz
    npm ERR! node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.1/napi-v6-darwin-x64.tar.gz
    npm ERR! node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (electron-v8.5 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.1/napi-v6-darwin-x64.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 | x64
    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 | x64
    npm ERR! gyp info find Python using Python version 3.8.2 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
    npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   '/usr/local/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/almad/Documents/projects/mytestproject/node_modules/sqlite3/build/config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/Users/almad/.electron-gyp/8.5.5/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/almad/.electron-gyp/8.5.5',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/almad/.electron-gyp/8.5.5/<(target_arch)/node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/almad/Documents/projects/mytestproject/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 | x64
    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! In file included from ../src/backup.cc:2:
    npm ERR! In file included from /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi.h:2636:
    npm ERR! /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi-inl.h:469:24: error: use of undeclared identifier 'napi_get_instance_data'
    npm ERR!   napi_status status = napi_get_instance_data(_env, &data);
    npm ERR!                        ^
    npm ERR! /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi-inl.h:791:24: error: use of undeclared identifier 'napi_create_bigint_int64'; did you mean 'napi_create_int64'?
    npm ERR!   napi_status status = napi_create_bigint_int64(env, val, &value);
    npm ERR!                        ^~~~~~~~~~~~~~~~~~~~~~~~
    npm ERR!                        napi_create_int64
    npm ERR! /Users/almad/.electron-gyp/8.5.5/include/node/js_native_api.h:74:25: note: 'napi_create_int64' declared here
    npm ERR! NAPI_EXTERN napi_status napi_create_int64(napi_env env,
    npm ERR!                         ^
    npm ERR! In file included from ../src/backup.cc:2:
    npm ERR! In file included from /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi.h:2636:
    npm ERR! /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi-inl.h:798:24: error: use of undeclared identifier 'napi_create_bigint_uint64'; did you mean 'napi_create_int64'?
    npm ERR!   napi_status status = napi_create_bigint_uint64(env, val, &value);
    npm ERR!                        ^~~~~~~~~~~~~~~~~~~~~~~~~
    npm ERR!                        napi_create_int64
    npm ERR! /Users/almad/.electron-gyp/8.5.5/include/node/js_native_api.h:74:25: note: 'napi_create_int64' declared here
    npm ERR! NAPI_EXTERN napi_status napi_create_int64(napi_env env,
    npm ERR!                         ^
    npm ERR! In file included from ../src/backup.cc:2:
    npm ERR! In file included from /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi.h:2636:
    npm ERR! /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi-inl.h:805:24: error: use of undeclared identifier 'napi_create_bigint_words'
    npm ERR!   napi_status status = napi_create_bigint_words(env, sign_bit, word_count, words, &value);
    npm ERR!                        ^
    npm ERR! /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi-inl.h:818:24: error: use of undeclared identifier 'napi_get_value_bigint_int64'
    npm ERR!   napi_status status = napi_get_value_bigint_int64(
    npm ERR!                        ^
    npm ERR! /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi-inl.h:826:24: error: use of undeclared identifier 'napi_get_value_bigint_uint64'
    npm ERR!   napi_status status = napi_get_value_bigint_uint64(
    npm ERR!                        ^
    npm ERR! /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi-inl.h:834:24: error: use of undeclared identifier 'napi_get_value_bigint_words'
    npm ERR!   napi_status status = napi_get_value_bigint_words(
    npm ERR!                        ^
    npm ERR! /Users/almad/Documents/projects/mytestproject/node_modules/node-addon-api/napi-inl.h:841:24: error: use of undeclared identifier 'napi_get_value_bigint_words'
    npm ERR!   napi_status status = napi_get_value_bigint_words(
    npm ERR!                        ^
    npm ERR! ../src/backup.cc:179:9: warning: unused variable 'status' [-Wunused-variable]
    npm ERR!     int status = napi_create_async_work(
    npm ERR!         ^
    npm ERR! ../src/backup.cc:252:5: warning: unused variable 'status' [-Wunused-variable]
    npm ERR!     BACKUP_BEGIN(Step);
    npm ERR!     ^
    npm ERR! ../src/macros.h:182:9: note: expanded from macro 'BACKUP_BEGIN'
    npm ERR!     int status = napi_create_async_work(                                       \
    npm ERR!         ^
    npm ERR! ../src/backup.cc:319:5: warning: unused variable 'status' [-Wunused-variable]
    npm ERR!     BACKUP_BEGIN(Finish);
    npm ERR!     ^
    npm ERR! ../src/macros.h:182:9: note: expanded from macro 'BACKUP_BEGIN'
    npm ERR!     int status = napi_create_async_work(                                       \
    npm ERR!         ^
    npm ERR! 3 warnings and 8 errors generated.
    npm ERR! make: *** [Release/obj.target/node_sqlite3/src/backup.o] 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 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
    npm ERR! gyp ERR! System Darwin 20.2.0
    npm ERR! gyp ERR! command "/usr/local/Cellar/node/15.3.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/almad/Documents/projects/mytestproject/node_modules/sqlite3/lib/binding/napi-v6-darwin-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/almad/Documents/projects/mytestproject/node_modules/sqlite3/lib/binding/napi-v6-darwin-x64" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=6" "--node_napi_label=napi-v6"
    npm ERR! gyp ERR! cwd /Users/almad/Documents/projects/mytestproject/node_modules/sqlite3
    npm ERR! gyp ERR! node -v v15.3.0
    npm ERR! gyp ERR! node-gyp -v v7.1.2
    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 '/usr/local/Cellar/node/15.3.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/almad/Documents/projects/mytestproject/node_modules/sqlite3/lib/binding/napi-v6-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/almad/Documents/projects/mytestproject/node_modules/sqlite3/lib/binding/napi-v6-darwin-x64 --napi_version=7 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/almad/Documents/projects/mytestproject/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
    npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1055:16)
    npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:288:5)
    npm ERR! node-pre-gyp ERR! System Darwin 20.2.0
    npm ERR! node-pre-gyp ERR! command "/usr/local/Cellar/node/15.3.0/bin/node" "/Users/almad/Documents/projects/mytestproject/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
    npm ERR! node-pre-gyp ERR! cwd /Users/almad/Documents/projects/mytestproject/node_modules/sqlite3
    npm ERR! node-pre-gyp ERR! node -v v15.3.0
    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/almad/.npm/_logs/2021-01-11T13_35_25_482Z-debug.log

                    command=/usr/local/Cellar/node/15.3.0/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js rebuild [email protected] [email protected] [email protected]
                    workingDir=
npm ERR! code 1
npm ERR! path /Users/almad/Documents/projects/mytestproject
npm ERR! command failed
npm ERR! command sh -c electron-builder install-app-deps

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/almad/.npm/_logs/2021-01-11T13_35_25_537Z-debug.log
@bgv2
Copy link

bgv2 commented Jan 12, 2021

Yeah, this seems to stem from #1421

@daniellockyer
Copy link
Member

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

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

No branches or pull requests

3 participants