如何在节点v10的Google Cloud Functions中使用ffi-napi

问题描述 投票:0回答:1

我在Google Cloud Function(节点v10)内部遇到本机模块依赖关系(特别是js的ibmmq)。它在Node v8引擎中运行良好,但是在升级引擎并遵循有关我的依赖关系的所有迁移指南之后,ffi-napi程序包在yarn install期间引发了异常,如下所示:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: ...s status = napi_get_instance_data(env, &d);
                        ^~~~~~~~~~~~~~~~~~~~~~
../src/ffi.cc:11:24: note: suggested alternative: 'napi_new_instance'
   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
   napi_status status = napi_set_instance_data(
                        ^~~~~~~~~~~~~~~~~~~~~~
../src/ffi.cc:347:24: note: suggested alternative: 'napi_new_instance'
   napi_status status = napi_set_instance_data(
                        ^~~~~~~~~~~~~~~~~~~~~~
                        napi_new_instance
In file included from ../src/ffi.cc:3:0:
../src/ffi.h: At global scope:
../src/ffi.h:148:19: warning: mangled name for 'Napi::TypedArray FFI::WrapPointer(Napi::Env, T*, size_t) [with T = char*() throw ()]' will change in C++17 because the exception specification is part of a function type [-Wnoexcept-type]
 inline TypedArray WrapPointer(Env env, T* ptr, size_t length = 0) {
                   ^~~~~~~~~~~
../src/ffi.h:148:19: warning: mangled name for 'Napi::TypedArray FFI::WrapPointer(Napi::Env, T*, size_t) [with T = void*(void*, const char*) throw ()]' will change in C++17 because the exception specification is part of a function type [-Wnoexcept-type]
../src/ffi.h:148:19: warning: mangled name for 'Napi::TypedArray FFI::WrapPointer(Napi::Env, T*, size_t) [with T = int(void*) throw ()]' will change in C++17 because the exception specification is part of a function type [-Wnoexcept-type]
../src/ffi.h:148:19: warning: mangled name for 'Napi::TypedArray FFI::WrapPointer(Napi::Env, T*, size_t) [with T = void*(const char*, int) throw ()]' will change in C++17 because the exception specification is part of a function type [-Wnoexcept-type]
make: *** [Release/obj.target/ffi_bindings/src/ffi.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:191: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.3.0-1020-gcp
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /workspace/node_modules/ffi-napi
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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!     /builder/home/.npm/_logs/2020-06-12T17_47_25_766Z-debug.log; Error ID: c4475859

它在本地(OSX Catalina节点10.21)和Docker(在基于高山的节点12)中都可以正常运行。

node.js google-cloud-platform google-cloud-functions ibm-mq n-api
1个回答
0
投票

TDLR:尚不支持。


[我刚刚发现Node v10.20(在v10.20.0中添加了napi_get_instance_data)引入了一些用于IBM MQ包依赖项(特别是ffi-napi)的本机API,但是Google Cloud Functions基于Node v10.18.1

到目前为止,我发现的唯一解决方法是使用纱线分辨率或自定义派生工具将ffi-napi降级为v2.4.7。没有有关Cloud Functions引擎中预期发布的Node v10.20的公共信息。

© www.soinside.com 2019 - 2024. All rights reserved.