node-ffi-napi / node-ffi-napi

A foreign function interface (FFI) for Node.js, N-API style
MIT License
978 stars 137 forks source link

npm install ffi-napi error on macOS #267

Open zoujiaqing opened 6 months ago

zoujiaqing commented 6 months ago
npm install ffi-napi
npm ERR! code 1
npm ERR! path /Users/zoujiaqing/projects/node_modules/ffi-napi
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR!   LIBTOOL-STATIC Release/nothing.a
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/prep_cif.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/types.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/raw_api.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/java_raw_api.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/closures.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/aarch64/ffi.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/aarch64/sysv.o
npm ERR!   LIBTOOL-STATIC Release/libffi.a
npm ERR!   CXX(target) Release/obj.target/ffi_bindings/src/ffi.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@21.6.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.11.7 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
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/zoujiaqing/projects/node_modules/ffi-napi/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/zoujiaqing/Library/Caches/node-gyp/21.6.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/zoujiaqing/Library/Caches/node-gyp/21.6.0',
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/zoujiaqing/Library/Caches/node-gyp/21.6.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/zoujiaqing/projects/node_modules/ffi-napi',
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! 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)
npm ERR! ../deps/libffi/src/java_raw_api.c:328:46: warning: 'ffi_java_raw_size' is deprecated [-Wdeprecated-declarations]
npm ERR!   ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif));
npm ERR!                                              ^
npm ERR! ../deps/libffi/config/mac/arm64/ffi.h:299:56: note: 'ffi_java_raw_size' has been explicitly marked deprecated here
npm ERR! size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated));
npm ERR!                                                        ^
npm ERR! ../deps/libffi/src/java_raw_api.c:331:3: warning: 'ffi_java_ptrarray_to_raw' is deprecated [-Wdeprecated-declarations]
npm ERR!   ffi_java_ptrarray_to_raw (cif, avalue, raw);
npm ERR!   ^
npm ERR! ../deps/libffi/config/mac/arm64/ffi.h:295:93: note: 'ffi_java_ptrarray_to_raw' has been explicitly marked deprecated here
npm ERR! void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) __attribute__((deprecated));
npm ERR!                                                                                             ^
npm ERR! 2 warnings generated.
npm ERR! ../deps/libffi/src/aarch64/ffi.c:738:17: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
npm ERR!       if (i + 1 == cif->aarch64_nfixedargs)
npm ERR!           ~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../deps/libffi/src/aarch64/ffi.c:991:17: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
npm ERR!       if (i + 1 == cif->aarch64_nfixedargs)
npm ERR!           ~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! 2 warnings generated.
npm ERR! In file included from ../src/ffi.cc:5:
npm ERR! /Users/zoujiaqing/projects/node_modules/get-uv-event-loop-napi-h/include/get-uv-event-loop-napi.h:26:30: error: incompatible function pointer types assigning to 'get_uv_event_loop_fn' (aka 'napi_status (*)(napi_env__ *, uv_loop_s **)') from 'napi_status (*)(node_api_nogc_env, struct uv_loop_s **)' (aka 'napi_status (*)(const napi_env__ *, uv_loop_s **)')
npm ERR!   napi_get_uv_event_loop__ = &napi_get_uv_event_loop;
npm ERR!                              ^~~~~~~~~~~~~~~~~~~~~~~
npm ERR! In file included from ../src/ffi.cc:3:
npm ERR! In file included from ../src/ffi.h:2:
npm ERR! In file included from /Users/zoujiaqing/projects/node_modules/node-addon-api/napi.h:2725:
npm ERR! /Users/zoujiaqing/projects/node_modules/node-addon-api/napi-inl.h:63:12: error: no matching function for call to 'napi_add_finalizer'
npm ERR!   status = napi_add_finalizer(env, obj, data, finalizer, hint, nullptr);
npm ERR!            ^~~~~~~~~~~~~~~~~~
npm ERR! /Users/zoujiaqing/projects/node_modules/node-addon-api/napi-inl.h:1965:29: note: in instantiation of function template specialization 'Napi::details::AttachData<Napi::details::CallbackData<Napi::Value (*)(const Napi::CallbackInfo &), Napi::Value>>' requested here
npm ERR!     status = Napi::details::AttachData(env, *result, data);
npm ERR!                             ^
npm ERR! /Users/zoujiaqing/projects/node_modules/node-addon-api/napi-inl.h:2021:24: note: in instantiation of function template specialization 'Napi::CreateFunction<Napi::details::CallbackData<Napi::Value (*)(const Napi::CallbackInfo &), Napi::Value>>' requested here
npm ERR!   napi_status status = CreateFunction(env,
npm ERR!                        ^
npm ERR! ../src/ffi.cc:58:38: note: in instantiation of function template specialization 'Napi::Function::New<Napi::Value (*)(const Napi::CallbackInfo &)>' requested here
npm ERR!   target["ffi_prep_cif"] = Function::New(env, FFIPrepCif);
npm ERR!                                      ^
npm ERR! /Users/zoujiaqing/Library/Caches/node-gyp/21.6.0/include/node/js_native_api.h:513:1: note: candidate function not viable: no known conversion from 'napi_finalize' (aka 'void (*)(napi_env__ *, void *, void *)') to 'node_api_nogc_finalize' (aka 'void (*)(const napi_env__ *, void *, void *)') for 4th argument
npm ERR! napi_add_finalizer(napi_env env,
npm ERR! ^
npm ERR! In file included from ../src/ffi.cc:3:
npm ERR! In file included from ../src/ffi.h:2:
npm ERR! In file included from /Users/zoujiaqing/projects/node_modules/node-addon-api/napi.h:2725:
npm ERR! /Users/zoujiaqing/projects/node_modules/node-addon-api/napi-inl.h:63:12: error: no matching function for call to 'napi_add_finalizer'
npm ERR!   status = napi_add_finalizer(env, obj, data, finalizer, hint, nullptr);
npm ERR!            ^~~~~~~~~~~~~~~~~~
npm ERR! /Users/zoujiaqing/projects/node_modules/node-addon-api/napi-inl.h:1965:29: note: in instantiation of function template specialization 'Napi::details::AttachData<Napi::details::CallbackData<void (*)(const Napi::CallbackInfo &), void>>' requested here
npm ERR!     status = Napi::details::AttachData(env, *result, data);
npm ERR!                             ^
npm ERR! /Users/zoujiaqing/projects/node_modules/node-addon-api/napi-inl.h:2021:24: note: in instantiation of function template specialization 'Napi::CreateFunction<Napi::details::CallbackData<void (*)(const Napi::CallbackInfo &), void>>' requested here
npm ERR!   napi_status status = CreateFunction(env,
npm ERR!                        ^
npm ERR! ../src/ffi.cc:60:34: note: in instantiation of function template specialization 'Napi::Function::New<void (*)(const Napi::CallbackInfo &)>' requested here
npm ERR!   target["ffi_call"] = Function::New(env, FFICall);
npm ERR!                                  ^
npm ERR! /Users/zoujiaqing/Library/Caches/node-gyp/21.6.0/include/node/js_native_api.h:513:1: note: candidate function not viable: no known conversion from 'napi_finalize' (aka 'void (*)(napi_env__ *, void *, void *)') to 'node_api_nogc_finalize' (aka 'void (*)(const napi_env__ *, void *, void *)') for 4th argument
npm ERR! napi_add_finalizer(napi_env env,
npm ERR! ^
npm ERR! 3 errors generated.
npm ERR! make: *** [Release/obj.target/ffi_bindings/src/ffi.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.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Darwin 23.2.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/21.6.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/zoujiaqing/projects/node_modules/ffi-napi
npm ERR! gyp ERR! node -v v21.6.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /Users/zoujiaqing/.npm/_logs/2024-01-22T04_42_26_345Z-debug-0.log
Marcjazz commented 5 months ago

I have simmilar issue on Ubuntu

npm ERR! code 1
npm ERR! path /home/mark/Projects/eudiw-app/node_modules/ffi-napi
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! make: Entering directory '/home/mark/Projects/eudiw-app/node_modules/ffi-napi/build'
npm ERR!   CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR! rm -f Release/obj.target/../node-addon-api/nothing.a Release/obj.target/../node-addon-api/nothing.a.ar-file-list; mkdir -p `dirname Release/obj.target/../node-addon-api/nothing.a`
npm ERR! ar crs Release/obj.target/../node-addon-api/nothing.a @Release/obj.target/../node-addon-api/nothing.a.ar-file-list
npm ERR!   COPY Release/nothing.a
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/prep_cif.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/types.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/raw_api.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/java_raw_api.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/closures.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/x86/ffiw64.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/x86/ffi64.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/x86/unix64.o
npm ERR!   CC(target) Release/obj.target/ffi/deps/libffi/src/x86/win64.o
npm ERR! rm -f Release/obj.target/deps/libffi/libffi.a Release/obj.target/deps/libffi/libffi.a.ar-file-list; mkdir -p `dirname Release/obj.target/deps/libffi/libffi.a`
npm ERR! ar crs Release/obj.target/deps/libffi/libffi.a @Release/obj.target/deps/libffi/libffi.a.ar-file-list
npm ERR!   COPY Release/libffi.a
npm ERR!   CXX(target) Release/obj.target/ffi_bindings/src/ffi.o
npm ERR! make: Leaving directory '/home/mark/Projects/eudiw-app/node_modules/ffi-napi/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@21.6.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/mark/.nvm/versions/node/v21.6.0/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 '/home/mark/Projects/eudiw-app/node_modules/ffi-napi/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/mark/.nvm/versions/node/v21.6.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/mark/.cache/node-gyp/21.6.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=/home/mark/.cache/node-gyp/21.6.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/mark/.nvm/versions/node/v21.6.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/mark/.cache/node-gyp/21.6.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/mark/Projects/eudiw-app/node_modules/ffi-napi',
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! ../deps/libffi/src/java_raw_api.c: In function ‘ffi_java_raw_call’:
npm ERR! ../deps/libffi/src/java_raw_api.c:317:3: warning: ‘ffi_java_raw_to_ptrarray’ is deprecated [-Wdeprecated-declarations]
npm ERR!   317 |   ffi_java_raw_to_ptrarray (cif, raw, avalue);
npm ERR!       |   ^~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../deps/libffi/src/java_raw_api.c:76:1: note: declared here
npm ERR!    76 | ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args)
npm ERR!       | ^~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../deps/libffi/src/java_raw_api.c: In function ‘ffi_java_translate_args’:
npm ERR! ../deps/libffi/src/java_raw_api.c:328:3: warning: ‘ffi_java_raw_size’ is deprecated [-Wdeprecated-declarations]
npm ERR!   328 |   ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif));
npm ERR!       |   ^~~~~~~~~~~~
npm ERR! ../deps/libffi/src/java_raw_api.c:45:1: note: declared here
npm ERR!    45 | ffi_java_raw_size (ffi_cif *cif)
npm ERR!       | ^~~~~~~~~~~~~~~~~
npm ERR! ../deps/libffi/src/java_raw_api.c:331:3: warning: ‘ffi_java_ptrarray_to_raw’ is deprecated [-Wdeprecated-declarations]
npm ERR!   331 |   ffi_java_ptrarray_to_raw (cif, avalue, raw);
npm ERR!       |   ^~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../deps/libffi/src/java_raw_api.c:157:1: note: declared here
npm ERR!   157 | ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw)
npm ERR!       | ^~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../deps/libffi/src/java_raw_api.c: In function ‘ffi_prep_java_raw_closure’:
npm ERR! ../deps/libffi/src/java_raw_api.c:369:3: warning: ‘ffi_prep_java_raw_closure_loc’ is deprecated [-Wdeprecated-declarations]
npm ERR!   369 |   return ffi_prep_java_raw_closure_loc (cl, cif, fun, user_data, cl);
npm ERR!       |   ^~~~~~
npm ERR! ../deps/libffi/src/java_raw_api.c:337:1: note: declared here
npm ERR!   337 | ffi_prep_java_raw_closure_loc (ffi_java_raw_closure* cl,
npm ERR!       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../deps/libffi/src/closures.c: In function ‘allocate_space’:
npm ERR! ../deps/libffi/src/closures.c:748:29: warning: comparison of integer expressions of different signedness: ‘off_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
npm ERR!   748 |       off_t to_write = (len < page_size) ? len : page_size;
npm ERR!       |                             ^
npm ERR! ../deps/libffi/src/closures.c:748:44: warning: operand of ‘?:’ changes signedness from ‘off_t’ {aka ‘long int’} to ‘size_t’ {aka ‘long unsigned int’} due to unsignedness of other operand [-Wsign-compare]
npm ERR!   748 |       off_t to_write = (len < page_size) ? len : page_size;
npm ERR!       |                                            ^~~
npm ERR! ../deps/libffi/src/x86/ffi64.c: In function ‘classify_argument’:
npm ERR! ../deps/libffi/src/x86/ffi64.c:200:25: warning: suggest braces around empty body in an ‘else’ statement [-Wempty-body]
npm ERR!   200 |           FFI_ASSERT (0);
npm ERR!       |                         ^
npm ERR! ../deps/libffi/src/x86/ffi64.c:175:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   175 |       {
npm ERR!       |       ^
npm ERR! ../deps/libffi/src/x86/ffi64.c:202:5: note: here
npm ERR!   202 |     case FFI_TYPE_FLOAT:
npm ERR!       |     ^~~~
npm ERR! In file included from ../src/ffi.cc:5:
npm ERR! /home/mark/Projects/eudiw-app/node_modules/get-uv-event-loop-napi-h/include/get-uv-event-loop-napi.h: In function ‘uv_loop_t* get_uv_event_loop(napi_env)’:
npm ERR! /home/mark/Projects/eudiw-app/node_modules/get-uv-event-loop-napi-h/include/get-uv-event-loop-napi.h:26:30: error: invalid conversion from ‘napi_status (*)(node_api_nogc_env, uv_loop_s**)’ {aka ‘napi_status (*)(const napi_env__*, uv_loop_s**)’} to ‘get_uv_event_loop_fn’ {aka ‘napi_status (*)(napi_env__*, uv_loop_s**)’} [-fpermissive]
npm ERR!    26 |   napi_get_uv_event_loop__ = &napi_get_uv_event_loop;
npm ERR!       |                              ^~~~~~~~~~~~~~~~~~~~~~~
npm ERR!       |                              |
npm ERR!       |                              napi_status (*)(node_api_nogc_env, uv_loop_s**) {aka napi_status (*)(const napi_env__*, uv_loop_s**)}
npm ERR! In file included from /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi.h:2725,
npm ERR!                  from ../src/ffi.h:2,
npm ERR!                  from ../src/ffi.cc:3:
npm ERR! /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi-inl.h: In instantiation of ‘napi_status Napi::details::AttachData(napi_env, napi_value, FreeType*, napi_finalize, void*) [with FreeType = Napi::details::CallbackData<Napi::Value (*)(const Napi::CallbackInfo&), Napi::Value>; napi_env = napi_env__*; napi_value = napi_value__*; napi_finalize = void (*)(napi_env__*, void*, void*)]’:
npm ERR! /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi-inl.h:1965:39:   required from ‘napi_status Napi::CreateFunction(napi_env, const char*, napi_callback, CbData*, napi_value__**) [with CbData = Napi::details::CallbackData<Napi::Value (*)(const Napi::CallbackInfo&), Napi::Value>; napi_env = napi_env__*; napi_callback = napi_value__* (*)(napi_env__*, napi_callback_info__*); napi_value = napi_value__*]’
npm ERR! /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi-inl.h:2021:38:   required from ‘static Napi::Function Napi::Function::New(napi_env, Callable, const char*, void*) [with Callable = Napi::Value (*)(const Napi::CallbackInfo&); napi_env = napi_env__*]’
npm ERR! ../src/ffi.cc:59:41:   required from here
npm ERR! /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi-inl.h:63:47: error: invalid conversion from ‘napi_finalize’ {aka ‘void (*)(napi_env__*, void*, void*)’} to ‘node_api_nogc_finalize’ {aka ‘void (*)(const napi_env__*, void*, void*)’} [-fpermissive]
npm ERR!    63 |   status = napi_add_finalizer(env, obj, data, finalizer, hint, nullptr);
npm ERR!       |                                               ^~~~~~~~~
npm ERR!       |                                               |
npm ERR!       |                                               napi_finalize {aka void (*)(napi_env__*, void*, void*)}
npm ERR! In file included from /home/mark/.cache/node-gyp/21.6.0/include/node/node_api.h:12,
npm ERR!                  from /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi.h:4,
npm ERR!                  from ../src/ffi.h:2,
npm ERR!                  from ../src/ffi.cc:3:
npm ERR! /home/mark/.cache/node-gyp/21.6.0/include/node/js_native_api.h:516:43: note:   initializing argument 4 of ‘napi_status napi_add_finalizer(napi_env, napi_value, void*, node_api_nogc_finalize, void*, napi_ref__**)’
npm ERR!   516 |                    node_api_nogc_finalize finalize_cb,
npm ERR!       |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
npm ERR! In file included from /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi.h:2725,
npm ERR!                  from ../src/ffi.h:2,
npm ERR!                  from ../src/ffi.cc:3:
npm ERR! /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi-inl.h: In instantiation of ‘napi_status Napi::details::AttachData(napi_env, napi_value, FreeType*, napi_finalize, void*) [with FreeType = Napi::details::CallbackData<void (*)(const Napi::CallbackInfo&), void>; napi_env = napi_env__*; napi_value = napi_value__*; napi_finalize = void (*)(napi_env__*, void*, void*)]’:
npm ERR! /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi-inl.h:1965:39:   required from ‘napi_status Napi::CreateFunction(napi_env, const char*, napi_callback, CbData*, napi_value__**) [with CbData = Napi::details::CallbackData<void (*)(const Napi::CallbackInfo&), void>; napi_env = napi_env__*; napi_callback = napi_value__* (*)(napi_env__*, napi_callback_info__*); napi_value = napi_value__*]’
npm ERR! /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi-inl.h:2021:38:   required from ‘static Napi::Function Napi::Function::New(napi_env, Callable, const char*, void*) [with Callable = void (*)(const Napi::CallbackInfo&); napi_env = napi_env__*]’
npm ERR! ../src/ffi.cc:61:37:   required from here
npm ERR! /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi-inl.h:63:47: error: invalid conversion from ‘napi_finalize’ {aka ‘void (*)(napi_env__*, void*, void*)’} to ‘node_api_nogc_finalize’ {aka ‘void (*)(const napi_env__*, void*, void*)’} [-fpermissive]
npm ERR!    63 |   status = napi_add_finalizer(env, obj, data, finalizer, hint, nullptr);
npm ERR!       |                                               ^~~~~~~~~
npm ERR!       |                                               |
npm ERR!       |                                               napi_finalize {aka void (*)(napi_env__*, void*, void*)}
npm ERR! In file included from /home/mark/.cache/node-gyp/21.6.0/include/node/node_api.h:12,
npm ERR!                  from /home/mark/Projects/eudiw-app/node_modules/node-addon-api/napi.h:4,
npm ERR!                  from ../src/ffi.h:2,
npm ERR!                  from ../src/ffi.cc:3:
npm ERR! /home/mark/.cache/node-gyp/21.6.0/include/node/js_native_api.h:516:43: note:   initializing argument 4 of ‘napi_status napi_add_finalizer(napi_env, napi_value, void*, node_api_nogc_finalize, void*, napi_ref__**)’
npm ERR!   516 |                    node_api_nogc_finalize finalize_cb,
npm ERR!       |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
npm ERR! make: *** [ffi_bindings.target.mk:121: Release/obj.target/ffi_bindings/src/ffi.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.<anonymous> (/home/mark/.nvm/versions/node/v21.6.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 6.1.0-1008-oem
npm ERR! gyp ERR! command "/home/mark/.nvm/versions/node/v21.6.0/bin/node" "/home/mark/.nvm/versions/node/v21.6.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/mark/Projects/eudiw-app/node_modules/ffi-napi
npm ERR! gyp ERR! node -v v21.6.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /home/mark/.npm/_logs/2024-02-01T10_40_09_787Z-debug-0.log
Rex-xingjl commented 4 months ago

Have you resolved it ? I got the same error.

jcardonne commented 4 months ago

Got the same error, any solution?

andrewtet commented 4 months ago

It seems like it's something to do with node 21. I rolled back to node 20 just to check and it installs just fine.

cclauss commented 4 months ago

Yes. This repo runs its AppVeyor and GitHub Actions tests on Node v14 so I am not surprised that it fails on modern versions of Node.js.

lingyuj commented 4 months ago

Got the same error. I'm wondering if this module will be updated for node 21 since the last update is 3 years ago.

Munaro commented 4 months ago

Same error here too!

lingyuj commented 3 months ago

Versions that work: ~ 20.11.1, ~ 21.5.0 Versions that broke ffi-napi: 20.12.0, 21.6.0 ~ So it seems the latest minor version update of node.js broke ffi-napi's compaibility.

lingyuj commented 3 months ago

I have raised an issue here : https://github.com/nodejs/node/issues/52240

cclauss commented 3 months ago

Can you folks please try out these steps on macOS? https://github.com/node-ffi-napi/node-ffi-napi/pull/270/files

I did node-gyp configure && node-gyp build instead of node-gyp-build.

What version of node-gyp-build are you using? With prebuildify?