Error when running npm install
heyitsvajid opened this issue ยท 16 comments
vkagdi$ node --version
v8.16.1
vkagdi$ npm --version
6.4.1
Getting below error when trying to install this module on Mac. We are using hbase
module and it has kerberos authentication. So we need this module to enable authentication to HBase from NodeJS.
LM-SJN-40004088:server vkagdi$ npm install krb5 --save
> krb5@0.5.1 install /Users/.../server/node_modules/krb5
> node-gyp rebuild
CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
LIBTOOL-STATIC Release/nothing.a
CXX(target) Release/obj.target/krb5/src/module.o
In file included from ../src/module.cc:1:
In file included from ../src/krb5_bind.h:1:
/Users/.../server/node_modules/node-addon-api/napi.h:31:6: error: Exception support not detected. Define either NAPI_CPP_EXCEPTIONS or
NAPI_DISABLE_CPP_EXCEPTIONS.
#error Exception support not detected. \
^
1 error generated.
make: *** [Release/obj.target/krb5/src/module.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/Cellar/node@8/8.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/Cellar/node@8/8.16.1/bin/node" "/usr/local/Cellar/node@8/8.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/...server/node_modules/krb5
gyp ERR! node -v v8.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN customerjourneynodeweb@2.3.0 No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! krb5@0.5.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the krb5@0.5.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/vkagdi/.npm/_logs/2019-08-26T17_40_07_693Z-debug.log
+1
Can anyone try building with the last commit on OSX to test before publishing on npm?
I tried, with no success. @RReivax remind me to look toguether on the train on sunday evening
OSX is now working.
From the OSX section on the readme:
Python 2 must be available in your path. You can check it by running
python --version
. It should something like "Python 2.7.16". If not, you must ensure that python 2 is used, for by placing back the original path:PATH="/usr/bin:$PATH" npm install
Same problem here. I have python in the project path, and it says the same problem described by @heyitsvajid
/usr/bin/python is v2.7.18 on my system, and it still appears to choose python3 for me.
PATH="/usr/bin:$PATH" npm install krb5
npm ERR! code 1
npm ERR! path /Users/myUser/repos/misc/myProj/node_modules/krb5
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
npm ERR! LIBTOOL-STATIC Release/nothing.a
npm ERR! CXX(target) Release/obj.target/krb5/src/module.o
npm ERR! CXX(target) Release/obj.target/krb5/src/krb5_bind.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@14.17.0 | darwin | x64
npm ERR! gyp info find Python using Python version 3.8.9 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',
OS: macOS Monterey
node: 14.17.0
npm: 8.1.1
With latest version, it's python 3 that is required to build the shared library.
Node-gyp dropped the python 2 support
Can you give the full log ?
Sure, please see attached
output.log
debug.log
.
This is not a python related issue, but a compilation one.
The error is that we give a const pointer to a function waiting for a non-const pointer (Meaning we're giving something that shouldn't be changed to something that can change it, which is a big no-no).
The two functions are:
krb5_get_init_creds_password
krb5_get_init_creds_keytab
I'll take krb5_get_init_creds_password
as an example.
Error:
npm ERR! ../src/krb5_bind.cc:635:13: error: no matching function for call to 'krb5_get_init_creds_password'
npm ERR! err = krb5_get_init_creds_password(krb_context,
npm ERR! ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/krb5/krb5.h:2302:1: note: candidate function not viable: 4th argument ('const std::basic_string<char>::value_type *' (aka 'const char *')) would lose const qualifier
npm ERR! krb5_get_init_creds_password
npm ERR! ^
Function signature from krb5.h:
krb5_get_init_creds_password(krb5_context context, krb5_creds *creds,
krb5_principal client, const char *password,
krb5_prompter_fct prompter, void *data,
krb5_deltat start_time,
const char *in_tkt_service,
krb5_get_init_creds_opt *k5_gic_options);
What we do is:
err = krb5_get_init_creds_password(krb_context,
&creds,
krb_princ,
krb_password.c_str(),
nullptr,
nullptr,
0,
NULL,
nullptr);
As you can see, the 4th argument is krb_password.c_str()
, which, called on a string returns a const char*
, which matches the function definition.
Therefore, there must be a problem with either your libc (but your libc seems to return the right type), or your libkrb5 includes.
How did you install libkrb5 ? and what is its version ?
(Note that we compile this library at version 1.16.1)
Glancing at the logs, looks it's coming down from an official Apple SDK?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/krb5/krb5.h:
Not sure how to check that version.
However, I do have krb5 installed via Brew (v1.19.2):
/usr/local/Cellar/krb5/1.19.2
Can you try :
export KRB5_HOME="/usr/local/Cellar/krb5/1.19.2"
npm install
(or KRB5_HOME="/usr/local/Cellar/krb5/1.19.2" npm install
)
Same thing I'm afraid, seems to ignore and use the SDK version?
Oh, I just checked, we're looking for this variable only in zOS, therefore it will not work on MacOS.
(I do not have a MacOs to try these out).
Can you try editing the binding.gyp to tell the compiler how to find the right lib on your system ?
Like in the zOS section.
OR try this
Since I don't know your compiler, I don't know if this will help you, but on Ubuntu, using GCC, I can do the following:
export LIBRARY_PATH="/path/to/krb5-1.16.1/lib" # where the shared libraries are
export CPLUS_INCLUDE_PATH="/path/to/krb5-1.16.1/include" # where the headers are
In any case, it might be good to have the same possibilities as for zOS and specify the lib + header paths
Here is the output of brew install krb5
:
brew install krb5 ~/projects/github/krb5
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/core, homebrew/cask and homebrew/bundle).
==> New Formulae
bk brev csview kyverno
==> Updated Formulae
Updated 62 formulae.
==> Updated Casks
Updated 53 casks.
==> Downloading https://ghcr.io/v2/homebrew/core/krb5/manifests/1.19.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/krb5/blobs/sha256:0dd1072480422dc447c27e560e6e09afc095d93f5edb0ca2b46183a972f8cab0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:0dd1072480422dc447c27e560e6e09afc095d93f5edb0ca2b46183a972f8cab0?se=2022-02-16T15%3A30%3A00Z&sig=qbHP6TfL6j0KOar
######################################################################## 100.0%
==> Pouring krb5--1.19.2.arm64_monterey.bottle.tar.gz
==> Caveats
krb5 is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have krb5 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/krb5/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/krb5/sbin:$PATH"' >> ~/.zshrc
For compilers to find krb5 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/krb5/lib"
export CPPFLAGS="-I/opt/homebrew/opt/krb5/include"
For pkg-config to find krb5 you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/krb5/lib/pkgconfig"
==> Summary
๐บ /opt/homebrew/Cellar/krb5/1.19.2: 162 files, 5.6MB
==> Running `brew cleanup krb5`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
The following succeed inside the project repository at npm install
:
export LDFLAGS="-L/opt/homebrew/opt/krb5/lib"
export CPPFLAGS="-I/opt/homebrew/opt/krb5/include"
npm install
This worked:
export LIBRARY_PATH="/usr/local/Cellar/krb5/1.19.2/lib"
export CPLUS_INCLUDE_PATH="/usr/local/Cellar/krb5/1.19.2/include"
npm install krb5
added 4 packages, and removed 7 packages in 7s
82 packages are looking for funding
runnpm fund
for details
Thank you very much!