joeferner / node-java

Bridge API to connect with existing Java APIs.
MIT License
1.88k stars 282 forks source link

npm install error with openjdk17, but works with openjdk15 #578

Open rsharma-prismhr opened 1 year ago

rsharma-prismhr commented 1 year ago

I am using node: 18 openJDK: 17 Docker image: node-18:alpine

But get this error when doing npm install on my project which uses java package:

npm ERR! code 1
npm ERR! path /home/app/node_modules/java
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/home/app/node_modules/java/build'
npm ERR!   CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o
npm ERR!   CXX(target) Release/obj.target/nodejavabridge_bindings/src/javaObject.o
npm ERR!   CXX(target) Release/obj.target/nodejavabridge_bindings/src/javaScope.o
npm ERR!   CXX(target) Release/obj.target/nodejavabridge_bindings/src/methodCallBaton.o
npm ERR!   CXX(target) Release/obj.target/nodejavabridge_bindings/src/nodeJavaBridge.o
npm ERR!   CXX(target) Release/obj.target/nodejavabridge_bindings/src/utils.o
npm ERR!   SOLINK_MODULE(target) Release/obj.target/nodejavabridge_bindings.node
npm ERR! make: Leaving directory '/home/app/node_modules/java/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@18.18.2 | linux | x64
npm ERR! gyp info find Python using Python version 3.11.6 found at "/usr/bin/python3"
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v18.18.2/node-v18.18.2-headers.tar.gz
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v18.18.2/node-v18.18.2-headers.tar.gz
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v18.18.2/SHASUMS256.txt
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v18.18.2/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/app/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/app/node_modules/java/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/app/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/app/.cache/node-gyp/18.18.2/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/app/.cache/node-gyp/18.18.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/app/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/app/.cache/node-gyp/18.18.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/app/node_modules/java',
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! In file included from ../src/java.h:9,
npm ERR!                  from ../src/java.cpp:1:

**********************************
Skipping mid of the error trace
**********************************

npm ERR!       |                                     ^~~
npm ERR! /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -ljvm: No such file or directory
npm ERR! collect2: error: ld returned 1 exit status
npm ERR! make: *** [nodejavabridge_bindings.target.mk:155: Release/obj.target/nodejavabridge_bindings.node] 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 (/home/app/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
npm ERR! gyp ERR! System Linux 5.15.49-linuxkit
npm ERR! gyp ERR! command "/usr/local/bin/node" "/home/app/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/app/node_modules/java
npm ERR! gyp ERR! node -v v18.18.2
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

When I use openjdk15, this issue doesn't happen, and I am in need of upgrading from 15 to 17. Please suggest.

UderMoreiraDeAssis commented 7 months ago

I am facing the same issue. Could you please inform if there is any possibility of assistance soon?