IBM / node-odbc

ODBC bindings for node
MIT License
146 stars 76 forks source link

[Help] Node pre gyp error when running npm install on MacOS #380

Closed maxkub47 closed 3 months ago

maxkub47 commented 5 months ago

I can install in windowOS but in macOS i found this error

npm ERR! code 1
npm ERR! path /Users/rattalig/Coding/demo_node_odbc/node_modules/odbc
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! CXX(target) Release/obj.target/odbc/src/odbc.o
npm ERR! Failed to execute '/opt/homebrew/Cellar/node@20/20.13.0/bin/node /opt/homebrew/Cellar/node@20/20.13.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc/lib/bindings/napi-v6/odbc.node --module_name=odbc --module_path=/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc/lib/bindings/napi-v6 --napi_version=9 --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 node-pre-gyp@1.0.11
npm ERR! node-pre-gyp info using node@20.13.0 | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc/lib/bindings/napi-v6/odbc.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-darwin-arm64-napi-v6.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-darwin-arm64-napi-v6.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for odbc@2.4.8 and node@20.13.0 (node-v115 ABI, unknown) (falling back to source compile with node-gyp) 
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-darwin-arm64-napi-v6.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.1.0
npm ERR! gyp info using node@20.13.0 | darwin | arm64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.1.0
npm ERR! gyp info using node@20.13.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.12.3 found at "/opt/homebrew/opt/python@3.12/bin/python3.12"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.12/bin/python3.12
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/opt/homebrew/Cellar/node@20/20.13.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 '/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/Cellar/node@20/20.13.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/rattalig/Library/Caches/node-gyp/20.13.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/rattalig/Library/Caches/node-gyp/20.13.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/Cellar/node@20/20.13.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/rattalig/Library/Caches/node-gyp/20.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc',
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 node-gyp@10.1.0
npm ERR! gyp info using node@20.13.0 | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../src/odbc.cpp:228:41: warning: comparison of array 'odbcError.state' not equal to a null pointer is always true [-Wtautological-pointer-compare]
npm ERR!       Napi::String::New(env, (odbcError.state != NULL) ? (const char*)odbcError.state : "")
npm ERR!                               ~~~~~~~~~~^~~~~    ~~~~
npm ERR! In file included from ../src/odbc.cpp:22:
npm ERR! In file included from ../src/odbc.h:27:
npm ERR! In file included from /Users/rattalig/Coding/demo_node_odbc/node_modules/node-addon-api/napi.h:2725:
npm ERR! /Users/rattalig/Coding/demo_node_odbc/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/rattalig/Coding/demo_node_odbc/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/rattalig/Coding/demo_node_odbc/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/odbc.cpp:148:42: note: in instantiation of function template specialization 'Napi::Function::New<Napi::Value (*)(const Napi::CallbackInfo &)>' requested here
npm ERR!   exports.Set("connect", Napi::Function::New(env, ODBC::Connect));
npm ERR!                                          ^
npm ERR! /Users/rattalig/Library/Caches/node-gyp/20.13.0/include/node/js_native_api.h:520: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! 1 warning and 1 error generated.
npm ERR! make: *** [Release/obj.target/odbc/src/odbc.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/Cellar/node@20/20.13.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Darwin 23.4.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node@20/20.13.0/bin/node" "/opt/homebrew/Cellar/node@20/20.13.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc/lib/bindings/napi-v6/odbc.node" "--module_name=odbc" "--module_path=/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc/lib/bindings/napi-v6" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=6" "--node_napi_label=napi-v6"
npm ERR! gyp ERR! cwd /Users/rattalig/Coding/demo_node_odbc/node_modules/odbc
npm ERR! gyp ERR! node -v v20.13.0
npm ERR! gyp ERR! node-gyp -v v10.1.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 '/opt/homebrew/Cellar/node@20/20.13.0/bin/node /opt/homebrew/Cellar/node@20/20.13.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc/lib/bindings/napi-v6/odbc.node --module_name=odbc --module_path=/Users/rattalig/Coding/demo_node_odbc/node_modules/odbc/lib/bindings/napi-v6 --napi_version=9 --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/rattalig/Coding/demo_node_odbc/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:519:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! node-pre-gyp ERR! System Darwin 23.4.0
npm ERR! node-pre-gyp ERR! command "/opt/homebrew/Cellar/node@20/20.13.0/bin/node" "/Users/rattalig/Coding/demo_node_odbc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/rattalig/Coding/demo_node_odbc/node_modules/odbc
npm ERR! node-pre-gyp ERR! node -v v20.13.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /Users/rattalig/.npm/_logs/2024-05-11T18_14_28_055Z-debug-0.log
acheronfail commented 5 months ago

I believe that error is because you're building with node 20, but this package only supports node 18 as per the README.

However, I get a similar error when building with node 18.20.2:

gyp info using node@18.20.2 | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/odbc/src/odbc.o
../src/odbc.cpp:228:41: warning: comparison of array 'odbcError.state' not equal to a null pointer is always true [-Wtautological-pointer-compare]
      Napi::String::New(env, (odbcError.state != NULL) ? (const char*)odbcError.state : "")
                              ~~~~~~~~~~^~~~~    ~~~~
In file included from ../src/odbc.cpp:22:
In file included from ../src/odbc.h:27:
In file included from /Users/acheronfail/path/to/my/project/node_modules/node-addon-api/napi.h:2725:
/Users/acheronfail/path/to/my/project/node_modules/node-addon-api/napi-inl.h:63:12: error: no matching function for call to 'napi_add_finalizer'
  status = napi_add_finalizer(env, obj, data, finalizer, hint, nullptr);
           ^~~~~~~~~~~~~~~~~~
/Users/acheronfail/path/to/my/project/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
    status = Napi::details::AttachData(env, *result, data);
                            ^
/Users/acheronfail/path/to/my/project/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
  napi_status status = CreateFunction(env,
                       ^
../src/odbc.cpp:148:42: note: in instantiation of function template specialization 'Napi::Function::New<Napi::Value (*)(const Napi::CallbackInfo &)>' requested here
  exports.Set("connect", Napi::Function::New(env, ODBC::Connect));
                                         ^
/Users/acheronfail/Library/Caches/node-gyp/18.20.2/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
napi_add_finalizer(napi_env env,
^
1 warning and 1 error generated.
make: *** [Release/obj.target/odbc/src/odbc.o] Error 1

which, according to the README should be supported!

maxkub47 commented 5 months ago

I tried to install both node18,20,22 but I got the same error. I think the download path not found "https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-darwin-arm64-napi-v6.tar.gz" because I went to look in that path and there are only x64 files, no arm64, but I don't know how to fix it. Screenshot 2024-05-13 101854

acheronfail commented 5 months ago

It's okay for there not to be prebuilt arm64 assets, as long as the fallback build script can build it locally. This works for me on node 18.18 (on arm, too!) but it doesn't for node 18.20, so there's an issue there.

I've been poking around the build setup for odbc, and I noticed if I remove the NAPI_EXPERIMENTAL defines from binding.gyp, then the build successfully completes when building for node 18.20. I have no idea if that breaks anything else, since I don't know how to run the test suite locally (seems it wants an ibmi database?)...

KerimG commented 5 months ago

@acheronfail that's weird. I tried installing with node 18.18.0, 18.18.2, 18.17.1 and got the error every time.

mbp ~/Code/sandbox % node -v
v18.18.0
mbp ~/Code/sandbox % npm i odbc
npm WARN skipping integrity check for git dependency ssh://git@github.com/jonschlinkert/is-true.git
npm WARN deprecated npmlog@5.0.1: This package is no longer supported.
npm WARN deprecated are-we-there-yet@2.0.0: This package is no longer supported.
npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support
npm WARN deprecated gauge@3.0.2: This package is no longer supported.
npm ERR! code 1
npm ERR! path /Users/kg/Code/sandbox/node_modules/odbc
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute '/Users/kg/.nvm/versions/node/v18.18.0/bin/node /Users/kg/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/kg/Code/sandbox/node_modules/odbc/lib/bindings/napi-v6/odbc.node --module_name=odbc --module_path=/Users/kg/Code/sandbox/node_modules/odbc/lib/bindings/napi-v6 --napi_version=9 --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 node-pre-gyp@1.0.11
npm ERR! node-pre-gyp info using node@18.18.0 | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/kg/Code/sandbox/node_modules/odbc/lib/bindings/napi-v6/odbc.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-darwin-arm64-napi-v6.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-darwin-arm64-napi-v6.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for odbc@2.4.8 and node@18.18.0 (node-v108 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-darwin-arm64-napi-v6.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@18.18.0 | darwin | arm64
...
brandonp42 commented 5 months ago

I'm running into the same issue with node 18.20 as well

pcrodrigues0 commented 4 months ago

Same issue here!

vincentB23 commented 3 months ago

I have the exact same issue unfortunately

p-kuen commented 3 months ago

When will this fix be released? We can't use the official npm version because of this.