My upgraded node-red module requires node v10+ to be able to execute N-API threadsafe functions.
Is there a way that this can be specified in the package.json file to prevent users without v10+ performing the upgrade (for example via the palette) and failing with compile errors (from node-gyp)?
However, by default, that will only produce an advisory warning in the log. Strict checking is only done if the user has enabled it in their own npm configuration.
Worth remembering that Node 8 is no longer maintained (as of a couple weeks ago) so users should really be on Node 10 at least.
I've added engines section now to my node module, but I still didn't get the advisory message using node v8.12 and node-red v0.8.4.
17 Jan 19:24:35 - [info] Upgrading module: node-red-contrib-energenie-ener314rt to version: 0.3.2
17 Jan 19:26:24 - [warn] Installation of module node-red-contrib-energenie-ener314rt failed:
17 Jan 19:26:24 - [warn] ------------------------------------------
17 Jan 19:26:24 - [warn]
energenie-ener314rt@0.3.2 install /home/pi/.node-red/node_modules/energenie-ener314rt
node-gyp rebuild
make: Entering directory '/home/pi/.node-red/node_modules/energenie-ener314rt/build'
CC(target) Release/obj.target/ener314rt/C/achronite/napi_energenie.o
../C/achronite/napi_energenie.c:58:5: error: unknown type name ânapi_threadsafe_functionâ
napi_threadsafe_function tsfn;
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../C/achronite/napi_energenie.c:4:0:
../C/achronite/napi_energenie.c: In function âtx_openThings_receive_threadâ:
../C/achronite/napi_energenie.c:628:12: warning: implicit declaration of function ânapi_acquire_threadsafe_functionâ [-Wimplicit-function-declaration]
assert(napi_acquire_threadsafe_function(addon_data->tsfn) == napi_ok);
^
../C/achronite/napi_energenie.c:645:20: warning: implicit declaration of function ânapi_call_threadsafe_functionâ [-Wimplicit-function-declaration]
assert(napi_call_threadsafe_function(addon_data->tsfn,
^
../C/achronite/napi_energenie.c:647:50: error: ânapi_tsfn_blockingâ undeclared (first use in this function)
napi_tsfn_blocking) == napi_ok);
^
../C/achronite/napi_energenie.c:647:50: note: each undeclared identifier is reported only once for each function it appears in
../C/achronite/napi_energenie.c:658:12: warning: implicit declaration of function ânapi_release_threadsafe_functionâ [-Wimplicit-function-declaration]
assert(napi_release_threadsafe_function(addon_data->tsfn, napi_tsfn_release) == napi_ok);
^
../C/achronite/napi_energenie.c:658:63: error: ânapi_tsfn_releaseâ undeclared (first use in this function)
assert(napi_release_threadsafe_function(addon_data->tsfn, napi_tsfn_release) == napi_ok);
^
../C/achronite/napi_energenie.c: In function âtc_openThings_receive_threadâ:
../C/achronite/napi_energenie.c:672:45: error: ânapi_tsfn_releaseâ undeclared (first use in this function)
napi_tsfn_release) == napi_ok);
^
../C/achronite/napi_energenie.c:677:22: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
addon_data->tsfn = NULL;
^
../C/achronite/napi_energenie.c: In function âtf_openThings_receive_threadâ:
../C/achronite/napi_energenie.c:747:22: warning: implicit declaration of function ânapi_create_threadsafe_functionâ [-Wimplicit-function-declaration]
status = napi_create_threadsafe_function(env,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ener314rt.target.mk:105: recipe for target 'Release/obj.target/ener314rt/C/achronite/napi_energenie.o' failed
make: Leaving directory '/home/pi/.node-red/node_modules/energenie-ener314rt/build'
make: *** [Release/obj.target/ener314rt/C/achronite/napi_energenie.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: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 Linux 4.14.71-v7+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/.node-red/node_modules/energenie-ener314rt
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN node-red-project@0.0.1 No repository field.
npm WARN node-red-project@0.0.1 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! energenie-ener314rt@0.3.2 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the energenie-ener314rt@0.3.2 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/pi/.npm/_logs/2020-01-17T19_26_23_021Z-debug.log
17 Jan 19:26:24 - [warn] ------------------------------------------