Error: make failed with exit code 2, while rebuilding serialport for Electron

I'm currently trying to recompile the binaries for serialport to work with electron. I have gotten to the point of being able to successfully run node-gyp configure and node-gyp rebuild on my serialport module within node_modules/serialport, however the module will not rebuild using electron-rebuild no matter what I try to do. Currently I am stuck with the error Error: make failed with exit code: 2 when I run npx electron-rebuild -f -w . directly in my node_modules/serialport folder. I get the same error running electron-rebuild -f -w . in my applications root folder.

My aim is to get serialport to run within an electron app running on a raspberry-pi 4 running rasbian. I'm using node v16.13.2 and npm v8.1.2. with serialport v9.2.8 and electron v16.0.6.

I have been stuck getting problems like this for much much longer than I would like to admit so any help at all would be fantastic.

The entire error log is included below:

npx electron-rebuild -f -w .

⠸ Building module: serialport, Completed: 0make: Entering directory '/home/pi/Documents/test/test2/node_modules/serialport/build'
  CXX(target) Release/obj.target/bindings/src/serialport.o
⠸ Building module: serialport, Completed: 0In file included from /home/pi/.electron-gyp/16.0.6/include/node/v8-local-handle.h:12,
                 from /home/pi/.electron-gyp/16.0.6/include/node/v8-array-buffer.h:12,
                 from /home/pi/.electron-gyp/16.0.6/include/node/v8.h:25,
                 from /home/pi/.electron-gyp/16.0.6/include/node/node.h:63,
                 from ../../nan/nan.h:58,
                 from ../src/./serialport.h:13,
                 from ../src/serialport.cpp:1:
/home/pi/.electron-gyp/16.0.6/include/node/v8-internal.h:113:27: error: static assertion failed: Pointer compression can be enabled only for 64-bit architectures
  113 |     kApiSystemPointerSize == kApiInt64Size,
      |     ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/home/pi/.electron-gyp/16.0.6/include/node/v8-internal.h:471:68: warning: left shift count >= width of type [-Wshift-count-overflow]
  471 | expr size_t kPtrComprCageReservationSize = size_t{1} << 32;
      |                                            ~~~~~~~~~~^~~~~

/home/pi/.electron-gyp/16.0.6/include/node/v8-internal.h:471:68: error: right operand of shift expression ‘(1 << 32)’ is greater than or equal to the precision 32 of the left operand [-fpermissive]
/home/pi/.electron-gyp/16.0.6/include/node/v8-internal.h:472:66: warning: left shift count >= width of type [-Wshift-count-overflow]
  472 | stexpr size_t kPtrComprCageBaseAlignment = size_t{1} << 32;
      |                                            ~~~~~~~~~~^~~~~

/home/pi/.electron-gyp/16.0.6/include/node/v8-internal.h:472:66: error: right operand of shift expression ‘(1 << 32)’ is greater than or equal to the precision 32 of the left operand [-fpermissive]
⠏ Building module: serialport, Completed: 0In file included from /home/pi/.electron-gyp/16.0.6/include/node/v8.h:53,
                 from /home/pi/.electron-gyp/16.0.6/include/node/node.h:63,
                 from ../../nan/nan.h:58,
                 from ../src/./serialport.h:13,
                 from ../src/serialport.cpp:1:
/home/pi/.electron-gyp/16.0.6/include/node/v8-script.h:230:79: warning: ‘using ResolveCallback = class v8::MaybeLocal<v8::Module> (*)(class v8::Local<v8::Context>, class v8::Local<v8::String>, class v8::Local<v8::Module>)’ is deprecated: Use ResolveModuleCallback [-Wdeprecated-declarations]
  230 |                                  ResolveCallback callback);
      |                                                          ^

/home/pi/.electron-gyp/16.0.6/include/node/v8-script.h:212:9: note: declared here
  212 |   using ResolveCallback V8_DEPRECATE_SOON("Use ResolveModuleCallback") =
      |         ^~~~~~~~~~~~~~~
⠇ Building module: serialport, Completed: 0../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:78:51: 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]
   78 | uv_queue_work(uv_default_loop(), req, EIO_Open, (uv_after_work_cb)EIO_AfterOpen);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Update(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:135:53: 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]
  135 | _queue_work(uv_default_loop(), req, EIO_Update, (uv_after_work_cb)EIO_AfterUpdate);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Close(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:175:52: 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]
  175 | v_queue_work(uv_default_loop(), req, EIO_Close, (uv_after_work_cb)EIO_AfterClose);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Flush(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:215:52: 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]
  215 | v_queue_work(uv_default_loop(), req, EIO_Flush, (uv_after_work_cb)EIO_AfterFlush);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Set(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:271:50: 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]
  271 |  uv_queue_work(uv_default_loop(), req, EIO_Set, (uv_after_work_cb)EIO_AfterSet);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Get(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:316:50: 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]
  316 |  uv_queue_work(uv_default_loop(), req, EIO_Get, (uv_after_work_cb)EIO_AfterGet);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

⠏ Building module: serialport, Completed: 0../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE GetBaudRate(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:366:58: 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]
  366 | e_work(uv_default_loop(), req, EIO_GetBaudRate, (uv_after_work_cb)EIO_AfterGetBaudRate);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Drain(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:412:52: 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]
  412 | v_queue_work(uv_default_loop(), req, EIO_Drain, (uv_after_work_cb)EIO_AfterDrain);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/serialport.cpp: At global scope:
../src/serialport.cpp:433:28: warning: unnecessary parentheses in declaration of ‘ToParityEnum’ [-Wparentheses]
  433 | SerialPortParity NAN_INLINE(ToParityEnum(const v8::Local<v8::String>& v8str)) {
      |                            ^
../src/serialport.cpp:452:30: warning: unnecessary parentheses in declaration of ‘ToStopBitEnum’ [-Wparentheses]
  452 | SerialPortStopBits NAN_INLINE(ToStopBitEnum(double stopBits)) {
      |                              ^
In file included from ../../nan/nan.h:58,
                 from ../src/./serialport.h:13,
                 from ../src/serialport.cpp:1:
/home/pi/.electron-gyp/16.0.6/include/node/node.h:821:7: 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]
  821 |       (node::addon_register_func) (regfunc),                          \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/.electron-gyp/16.0.6/include/node/node.h:855:3: note: in expansion of macro ‘NODE_MODULE_X’
  855 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/serialport.cpp:486:1: note: in expansion of macro ‘NODE_MODULE’
  486 | NODE_MODULE(serialport, init);
      | ^~~~~~~~~~~
⠸ Building module: serialport, Completed: 0make: *** [bindings.target.mk:124: Release/obj.target/bindings/src/serialport.o] Error 1
make: Leaving directory '/home/pi/Documents/test/test2/node_modules/serialport/build'
✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild '/home/pi/Documents/test/test2/node_modules/serialport'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `make` failed with exit code: 2



Error: node-gyp failed to rebuild '/home/pi/Documents/test/test2/node_modules/serialport'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `make` failed with exit code: 2


    at NodeGyp.rebuildModule (/home/pi/Documents/test/test2/node_modules/electron-rebuild/lib/src/module-type/node-gyp.js:117:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ModuleRebuilder.rebuildNodeGypModule (/home/pi/Documents/test/test2/node_modules/electron-rebuild/lib/src/module-rebuilder.js:94:9)
    at async ModuleRebuilder.rebuild (/home/pi/Documents/test/test2/node_modules/electron-rebuild/lib/src/module-rebuilder.js:124:14)
    at async Rebuilder.rebuildModuleAt (/home/pi/Documents/test/test2/node_modules/electron-rebuild/lib/src/rebuild.js:145:13)
    at async Rebuilder.rebuild (/home/pi/Documents/test/test2/node_modules/electron-rebuild/lib/src/rebuild.js:108:17)
    at async /home/pi/Documents/test/test2/node_modules/electron-rebuild/lib/src/cli.js:154:9

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum