我目前正在尝试重新编译串行端口的二进制文件以使用电子。我已经到了能够成功地run node-gyp configure
在node-gyp rebuild
我的串行端口模块上运行的地步node_modules/serialport
,但是无论我尝试做什么,该模块都不会使用电子重建来重建。目前,Error: make failed with exit code: 2
当我npx electron-rebuild -f -w .
直接在我的 node_modules/serialport 文件夹中运行时,我遇到了错误。electron-rebuild -f -w .
我在我的应用程序根文件夹中运行相同的错误。
我的目标是让串行端口在运行 rasbian 的 raspberry-pi 4 上运行的电子应用程序中运行。我正在使用节点 v16.13.2 和 npm v8.1.2。使用串口 v9.2.8 和电子 v16.0.6。
我遇到这样的问题的时间比我想承认的要长得多,所以任何帮助都会很棒。
整个错误日志包括在下面:
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