我想使用 TDengine nodejs 连接器与数据库连接。我按照https://www.taosdata.com/en/documentation/connector中的网站说明进行操作。我在下面遇到了错误。
sr@u195:~/files/connector/nodejs/example$ npm install td2.0-connector
> ref-napi@2.1.2 install /home/sr/files/connector/nodejs/example/node_modules/ffi-napi/node_modules/ref-napi
> node-gyp-build
> ffi-napi@3.1.0 install /home/sr/files/connector/nodejs/example/node_modules/ffi-napi
> node-gyp-build
make: Entering directory '/home/sr/files/connector/nodejs/example/node_modules/ffi-napi/build'
CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
AR(target) Release/obj.target/../node-addon-api/src/nothing.a
COPY Release/nothing.a
CC(target) Release/obj.target/ffi/deps/libffi/src/prep_cif.o
CC(target) Release/obj.target/ffi/deps/libffi/src/types.o
CC(target) Release/obj.target/ffi/deps/libffi/src/raw_api.o
CC(target) Release/obj.target/ffi/deps/libffi/src/java_raw_api.o
CC(target) Release/obj.target/ffi/deps/libffi/src/closures.o
../deps/libffi/src/closures.c: In function ‘dlmmap_locked’:
../deps/libffi/src/closures.c:421:7: warning: ignoring return value of ‘ftruncate’, declared with attribute warn_unused_result [-Wunused-result]
421 | ftruncate (execfd, offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/libffi/src/closures.c:433:7: warning: ignoring return value of ‘ftruncate’, declared with attribute warn_unused_result [-Wunused-result]
433 | ftruncate (execfd, offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
CC(target) Release/obj.target/ffi/deps/libffi/src/x86/ffi.o
CC(target) Release/obj.target/ffi/deps/libffi/src/x86/ffi64.o
../deps/libffi/src/x86/ffi64.c: In function ‘classify_argument’:
../deps/libffi/src/x86/ffi64.c:181:18: warning: suggest braces around empty body in an ‘else’ statement [-Wempty-body]
181 | FFI_ASSERT (0);
| ^
../deps/libffi/src/x86/ffi64.c:156:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
156 | {
| ^
../deps/libffi/src/x86/ffi64.c:183:5: note: here
183 | case FFI_TYPE_FLOAT:
| ^~~~
CC(target) Release/obj.target/ffi/deps/libffi/src/x86/unix64.o
CC(target) Release/obj.target/ffi/deps/libffi/src/x86/sysv.o
AR(target) Release/obj.target/deps/libffi/libffi.a
COPY Release/libffi.a
CXX(target) Release/obj.target/ffi_bindings/src/ffi.o
../src/ffi.cc: In static member function ‘static FFI::InstanceData* FFI::InstanceData::Get(Napi::Env)’:
../src/ffi.cc:11:24: error: ‘napi_get_instance_data’ was not declared in this scope; did you mean ‘napi_new_instance’?
11 | napi_status status = napi_get_instance_data(env, &d);
| ^~~~~~~~~~~~~~~~~~~~~~
| napi_new_instance
../src/ffi.cc: In function ‘Napi::Object BindingHook(Napi::Env, Napi::Object)’:
../src/ffi.cc:347:24: error: ‘napi_set_instance_data’ was not declared in this scope; did you mean ‘napi_new_instance’?
347 | napi_status status = napi_set_instance_data(
| ^~~~~~~~~~~~~~~~~~~~~~
| napi_new_instance
make: *** [ffi_bindings.target.mk:116: Release/obj.target/ffi_bindings/src/ffi.o] Error 1
make: Leaving directory '/home/sr/files/connector/nodejs/example/node_modules/ffi-napi/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/nodejs/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 5.4.0-80-generic
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/sr/files/connector/nodejs/example/node_modules/ffi-napi
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok
npm WARN example@1.0.0 No description
npm WARN example@1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ffi-napi@3.1.0 install: `node-gyp-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ffi-napi@3.1.0 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! /home/sr/.npm/_logs/2021-08-05T06_05_25_673Z-debug.log
我的环境是
sr@u195:~/files/connector/nodejs/example$ echo ${PATH}
/usr/bin/python2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games :/snap/bin:/home/sr/software/jdk1.8.0_291/bin:/home/sr/software/jdk1.8.0_291/jre/bin:/home/sr/software/go
sr@u195:~/files/connector/nodejs/example$ python
Python 2.7.18(默认,2021 年 3 月 8 日,13:02:45)
[GCC 9.3.0] 在 linux2 上
输入“帮助”、“版权”、“信用”或“许可”以获取更多信息。
sr@u195:~/files/connector/nodejs/example$ 哪个python
/usr/bin/python
sr@u195:~/files/connector/nodejs/example$ 其中python2
/usr/bin/python2
sr@u195:~/files/connector/nodejs/example$