Upgrade of Node.js V16 breaks nodes that use i2c - comm library related?

I have an application in my homse where I employ two identical RaspberryPi4Bs that run the same exact Flows. 1 of them is in production (rpi4b-prod), 1 of them is the guinea pig (rpi4b-dev) for trying out upgrades to find breaking changes before performing them on the production unit. i just move my ethernet cable, 3 i2c lines, and power plug from one to the other to flop back and forth between which one is active in use.

Successfully upgraded both to Node-red V2.1.3 (guinea pig first, then production) yesterday.

Today, I ran the script again to push Node.js from v12 to v16 (on the guinea pig of course). What I found was that i broke serveral nodes related to comms and i2c... I suspect there is an underlying comms library that doesn't pass the muster with v16.

I'll do further digging, but I thought that I would mention it in the event that others have experienced the same. I thought there was a thread about trying out v16 of node.js, but I can't find it... I thought that I had even commented on it, but I guess I didn't.

ncd-red-comm, ncd-red-mcp23008, ncd-red-contrib-i2c, ncd-red-contrib-ezo.

Did you do a rebuild? It is very typical, to need to to rebuild all the C libraries when you move between Node.js major versions.

No, I did not. I wouldn't know how to begin to recompile/rebuild libraries contributed by other people for these user contributed nodes in question. I mean I'm capable of undertaking the effort, just have never had to do it before, so it will be an entire learning endeavor unto itself.

:grinning: not to worry, it is very easy.

All you need to do is drop to a command prompt then:

cd ~/.node-red
npm rebuild

Then restart node-red.

npm-rebuild | npm Docs (npmjs.com)

Simple!

did it. Looks like I have some research to do. oh well...



npm ERR! code 1
npm ERR! path /home/pi/.node-red/node_modules/ncd-red-comm/node_modules/@serialport/bindings
npm ERR! command failed
npm ERR! command sh -c prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
npm ERR! make: Entering directory '/home/pi/.node-red/node_modules/ncd-red-comm/node_modules/@serialport/bindings/build'
npm ERR!   CXX(target) Release/obj.target/bindings/src/serialport.o
npm ERR! make: Leaving directory '/home/pi/.node-red/node_modules/ncd-red-comm/node_modules/@serialport/bindings/build'
npm ERR! prebuild-install WARN install No prebuilt binaries found (target=16.13.0 runtime=node arch=arm libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.4.0
npm ERR! gyp info using node@16.13.0 | linux | arm
npm ERR! (node:872) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp info spawn /usr/bin/python2
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/pi/.node-red/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/pi/.node-red/node_modules/ncd-red-comm/node_modules/@serialport/bindings/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/pi/.node-red/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/pi/.node-gyp/16.13.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/pi/.node-gyp/16.13.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/pi/.node-red/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/pi/.node-red/node_modules/ncd-red-comm/node_modules/@serialport/bindings',
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! ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/serialport.cpp:78:69: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!    uv_queue_work(uv_default_loop(), req, EIO_Open, (uv_after_work_cb)EIO_AfterOpen);
npm ERR!                                                                      ^~~~~~~~~~~~~
npm ERR! ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Update(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/serialport.cpp:135:71: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!    uv_queue_work(uv_default_loop(), req, EIO_Update, (uv_after_work_cb)EIO_AfterUpdate);
npm ERR!                                                                        ^~~~~~~~~~~~~~~
npm ERR! ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Close(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/serialport.cpp:175:70: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!    uv_queue_work(uv_default_loop(), req, EIO_Close, (uv_after_work_cb)EIO_AfterClose);
npm ERR!                                                                       ^~~~~~~~~~~~~~
npm ERR! ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Flush(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/serialport.cpp:215:70: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!    uv_queue_work(uv_default_loop(), req, EIO_Flush, (uv_after_work_cb)EIO_AfterFlush);
npm ERR!                                                                       ^~~~~~~~~~~~~~
npm ERR! ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Set(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/serialport.cpp:270:68: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!    uv_queue_work(uv_default_loop(), req, EIO_Set, (uv_after_work_cb)EIO_AfterSet);
npm ERR!                                                                     ^~~~~~~~~~~~
npm ERR! ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Get(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/serialport.cpp:314:68: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!    uv_queue_work(uv_default_loop(), req, EIO_Get, (uv_after_work_cb)EIO_AfterGet);
npm ERR!                                                                     ^~~~~~~~~~~~
npm ERR! ../src/serialport.cpp: In function ‘void EIO_AfterGet(uv_work_t*)’:
npm ERR! ../src/serialport.cpp:329:96: error: no matching function for call to ‘v8::Object::Set(v8::Local<v8::String>, Nan::imp::FactoryBase<v8::Boolean>::return_t)’
npm ERR!      results->Set(Nan::New<v8::String>("cts").ToLocalChecked(), Nan::New<v8::Boolean>(data->cts));
npm ERR!                                                                                                 ^
npm ERR! In file included from /home/pi/.node-gyp/16.13.0/include/node/node.h:63,
npm ERR!                  from ../../../../../nan/nan.h:58,
npm ERR!                  from ../src/./serialport.h:6,
npm ERR!                  from ../src/serialport.cpp:1:
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3961:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’
npm ERR!    V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
npm ERR!                                      ^~~
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3961:37: note:   candidate expects 3 arguments, 2 provided
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3964:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’
npm ERR!    V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
npm ERR!                                      ^~~
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3964:37: note:   candidate expects 3 arguments, 2 provided
npm ERR! ../src/serialport.cpp:330:96: error: no matching function for call to ‘v8::Object::Set(v8::Local<v8::String>, Nan::imp::FactoryBase<v8::Boolean>::return_t)’
npm ERR!      results->Set(Nan::New<v8::String>("dsr").ToLocalChecked(), Nan::New<v8::Boolean>(data->dsr));
npm ERR!                                                                                                 ^
npm ERR! In file included from /home/pi/.node-gyp/16.13.0/include/node/node.h:63,
npm ERR!                  from ../../../../../nan/nan.h:58,
npm ERR!                  from ../src/./serialport.h:6,
npm ERR!                  from ../src/serialport.cpp:1:
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3961:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’
npm ERR!    V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
npm ERR!                                      ^~~
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3961:37: note:   candidate expects 3 arguments, 2 provided
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3964:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’
npm ERR!    V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
npm ERR!                                      ^~~
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3964:37: note:   candidate expects 3 arguments, 2 provided
npm ERR! ../src/serialport.cpp:331:96: error: no matching function for call to ‘v8::Object::Set(v8::Local<v8::String>, Nan::imp::FactoryBase<v8::Boolean>::return_t)’
npm ERR!      results->Set(Nan::New<v8::String>("dcd").ToLocalChecked(), Nan::New<v8::Boolean>(data->dcd));
npm ERR!                                                                                                 ^
npm ERR! In file included from /home/pi/.node-gyp/16.13.0/include/node/node.h:63,
npm ERR!                  from ../../../../../nan/nan.h:58,
npm ERR!                  from ../src/./serialport.h:6,
npm ERR!                  from ../src/serialport.cpp:1:
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3961:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’
npm ERR!    V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
npm ERR!                                      ^~~
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3961:37: note:   candidate expects 3 arguments, 2 provided
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3964:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’
npm ERR!    V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
npm ERR!                                      ^~~
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3964:37: note:   candidate expects 3 arguments, 2 provided
npm ERR! ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE GetBaudRate(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/serialport.cpp:363:76: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!    uv_queue_work(uv_default_loop(), req, EIO_GetBaudRate, (uv_after_work_cb)EIO_AfterGetBaudRate);
npm ERR!                                                                             ^~~~~~~~~~~~~~~~~~~~
npm ERR! ../src/serialport.cpp: In function ‘void EIO_AfterGetBaudRate(uv_work_t*)’:
npm ERR! ../src/serialport.cpp:378:106: error: no matching function for call to ‘v8::Object::Set(v8::Local<v8::String>, Nan::imp::IntegerFactory<v8::Integer>::return_t)’
npm ERR!      results->Set(Nan::New<v8::String>("baudRate").ToLocalChecked(), Nan::New<v8::Integer>(data->baudRate));
npm ERR!                                                                                                           ^
npm ERR! In file included from /home/pi/.node-gyp/16.13.0/include/node/node.h:63,
npm ERR!                  from ../../../../../nan/nan.h:58,
npm ERR!                  from ../src/./serialport.h:6,
npm ERR!                  from ../src/serialport.cpp:1:
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3961:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’
npm ERR!    V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
npm ERR!                                      ^~~
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3961:37: note:   candidate expects 3 arguments, 2 provided
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3964:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’
npm ERR!    V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
npm ERR!                                      ^~~
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/v8.h:3964:37: note:   candidate expects 3 arguments, 2 provided
npm ERR! ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Drain(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/serialport.cpp:409:70: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!    uv_queue_work(uv_default_loop(), req, EIO_Drain, (uv_after_work_cb)EIO_AfterDrain);
npm ERR!                                                                       ^~~~~~~~~~~~~~
npm ERR! ../src/serialport.cpp: At global scope:
npm ERR! ../src/serialport.cpp:430:28: warning: unnecessary parentheses in declaration of ‘ToParityEnum’ [-Wparentheses]
npm ERR!  SerialPortParity NAN_INLINE(ToParityEnum(const v8::Local<v8::String>& v8str)) {
npm ERR!                             ^
npm ERR! ../src/serialport.cpp:449:30: warning: unnecessary parentheses in declaration of ‘ToStopBitEnum’ [-Wparentheses]
npm ERR!  SerialPortStopBits NAN_INLINE(ToStopBitEnum(double stopBits)) {
npm ERR!                               ^
npm ERR! In file included from ../../../../../nan/nan.h:58,
npm ERR!                  from ../src/./serialport.h:6,
npm ERR!                  from ../src/serialport.cpp:1:
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/node.h:821:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm ERR!        (node::addon_register_func) (regfunc),                          \
npm ERR!                                            ^
npm ERR! /home/pi/.node-gyp/16.13.0/include/node/node.h:855:3: note: in expansion of macro ‘NODE_MODULE_X’
npm ERR!    NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!    ^~~~~~~~~~~~~
npm ERR! ../src/serialport.cpp:483:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR!  NODE_MODULE(serialport, init);
npm ERR!  ^~~~~~~~~~~
npm ERR! make: *** [bindings.target.mk:108: Release/obj.target/bindings/src/serialport.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 (/home/pi/.node-red/node_modules/node-gyp/lib/build.js:276:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 5.10.63-v7l+
npm ERR! gyp ERR! command "/usr/bin/node" "/home/pi/.node-red/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/pi/.node-red/node_modules/ncd-red-comm/node_modules/@serialport/bindings
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.4.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2021-11-02T21_22_06_028Z-debug.log

Did you upgrade all the nodes to the latest before upgrading nodejs? Though it may be that ncd-red-comm pulls in an out of date version of serialport. Try

cd ~/.node-red
npm remove ncd-red-comm
npm install ncd-red-comm

Yeah,
didn't work. good news is I see that the maintainger of this node... ncd-red-comm.. just updated it 13 days ago.. so I shot him a message on github. This node is the basis for all other ncd node-red nodes as well, so maybe it will fix the ncd.mcp23008 issue too

The contrib-i2c and the contrib-ezo.. those use and underlying library called the i2c-bus and the author of that claims capability with node.js v16.. nevertheless, i sent messages to him as well.

I can install ncd-red-comm ok here, on Ubuntu with nodejs 16. Can you go to your .node-red folder and run
npm remove ncd-red-comm
npm install ncd-red-comm
and post the full output here please.