从Node.js连接到JDBC驱动程序

vngu2lb8  于 2023-11-17  发布在  Node.js
关注(0)|答案(1)|浏览(208)

我正在尝试从Node.js连接到JDBC driver。我按照这里的说明操作:
https://www.npmjs.com/package/jdbc
我从Github下载了这个项目,并在项目目录中尝试安装它:

npm i --python="/usr/local/bin/python3.11" jdbc

字符串
然而,这并没有成功。我得到了以下错误,我觉得很难理解:

me@me:~/PROJECTS/node-jdbc-master$ npm i --python="/usr/local/bin/python3.11" jdbc
npm WARN deprecated [email protected]: do not use this version, it is broken
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: lolex has been renamed to @sinonjs/fake-timers. No API changes made. Please use the new package instead
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: you are strongly encouraged to use other testing options
npm ERR! code 1
npm ERR! path /home/me/PROJECTS/node-jdbc-master/node_modules/java
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/home/me/PROJECTS/node-jdbc-master/node_modules/java/build'
npm ERR!   CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o
npm ERR! nodejavabridge_bindings.target.mk:124: recipe for target 'Release/obj.target/nodejavabridge_bindings/src/java.o' failed
npm ERR! make: Leaving directory '/home/me/PROJECTS/node-jdbc-master/node_modules/java/build'
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] | linux | x64
npm ERR! gyp info find Python using Python version 3.11.0 found at "/usr/local/bin/python3.11"
npm ERR! gyp info spawn /usr/local/bin/python3.11
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   '/home/me/PROJECTS/node-jdbc-master/node_modules/java/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   '/home/me/.cache/node-gyp/17.9.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/me/.cache/node-gyp/17.9.0',
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=/home/me/.cache/node-gyp/17.9.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/me/PROJECTS/node-jdbc-master/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 ../../nan/nan.h:2884:0,
npm ERR!                  from ../src/java.h:9,
npm ERR!                  from ../src/java.cpp:1:
npm ERR! ../../nan/nan_typedarray_contents.h: In constructor ‘Nan::TypedArrayContents<T>::TypedArrayContents(v8::Local<v8::Value>)’:
npm ERR! ../../nan/nan_typedarray_contents.h:34:43: error: ‘class v8::ArrayBuffer’ has no member named ‘GetContents’
npm ERR!        data   = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
npm ERR!                                            ^
npm ERR! make: *** [Release/obj.target/nodejavabridge_bindings/src/java.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:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 4.4.0-146-generic
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/me/PROJECTS/node-jdbc-master/node_modules/java
npm ERR! gyp ERR! node -v v17.9.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/me/.npm/_logs/2022-04-19T18_56_54_389Z-debug-0.log
me@me:~/PROJECTS/node-jdbc-master$


我到底做错了什么
我使用的Java版本不支持吗?

$ java -version
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

7uzetpgm

7uzetpgm1#

有些节点模块没有编译。它们是纯源代码,允许它们在不同的架构中工作。问题是:它们需要编译。这就是node-gyp试图做的事情。它反过来调用'make'模块,该模块用于编译C代码。在这一点上,它需要适当的C编译库。你缺少这些库。
从哪里获得这些可能很棘手。我通常下载并安装C运行时环境(只是谷歌它),这通常会成功。我被告知安装Visual Studio也可以。显然,你需要的关键文件是MSBuild.exe。
因此,请确保您安装了正确版本的python,安装了node-gyp,make,并安装了C
(要么是C运行时,或者您可以尝试g模块,我从未使用过)。看起来'java'模块正在触发此过程,因此检查the java modules documentation
更多信息here.

相关问题