node-rpi-ws281x-native: Build errors on RaspberryPi4

Hi! I get lots of build errors when trying to npm install rpi-ws281x-native on a Raspi4 (Raspbian buster 4.19.97). (node-gyp rebuild fails at the nan module.)

I tried different versions of node (10.0.0, 12.13.1, 13.12.0, 14.1.0). Any ideas how to deal with this?

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 36 (7 by maintainers)

Most upvoted comments

any updates on this PR? I to am having some issue on build.

239 error make: Leaving directory '/home/pi/ext_nisa/node_modules/rpi-ws281x-native/build'
240 error gyp info it worked if it ends with ok
240 error gyp info using node-gyp@7.1.2
240 error gyp info using node@14.17.0 | linux | arm
240 error gyp info find Python using Python version 3.7.3 found at "/usr/bin/python3"
240 error gyp info spawn /usr/bin/python3
240 error gyp info spawn args [
240 error gyp info spawn args   '/home/pi/ext_nisa/node_modules/node-gyp/gyp/gyp_main.py',
240 error gyp info spawn args   'binding.gyp',
240 error gyp info spawn args   '-f',
240 error gyp info spawn args   'make',
240 error gyp info spawn args   '-I',
240 error gyp info spawn args   '/home/pi/ext_nisa/node_modules/rpi-ws281x-native/build/config.gypi',
240 error gyp info spawn args   '-I',
240 error gyp info spawn args   '/home/pi/ext_nisa/node_modules/node-gyp/addon.gypi',
240 error gyp info spawn args   '-I',
240 error gyp info spawn args   '/home/pi/.cache/node-gyp/14.17.0/include/node/common.gypi',
240 error gyp info spawn args   '-Dlibrary=shared_library',
240 error gyp info spawn args   '-Dvisibility=default',
240 error gyp info spawn args   '-Dnode_root_dir=/home/pi/.cache/node-gyp/14.17.0',
240 error gyp info spawn args   '-Dnode_gyp_dir=/home/pi/ext_nisa/node_modules/node-gyp',
240 error gyp info spawn args   '-Dnode_lib_file=/home/pi/.cache/node-gyp/14.17.0/<(target_arch)/node.lib',
240 error gyp info spawn args   '-Dmodule_root_dir=/home/pi/ext_nisa/node_modules/rpi-ws281x-native',
240 error gyp info spawn args   '-Dnode_engine=v8',
240 error gyp info spawn args   '--depth=.',
240 error gyp info spawn args   '--no-parallel',
240 error gyp info spawn args   '--generator-output',
240 error gyp info spawn args   'build',
240 error gyp info spawn args   '-Goutput_dir=.'
240 error gyp info spawn args ]
240 error gyp info spawn make
240 error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
240 error ../src/rpi-ws281x.cc: In function ‘void InitAll(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’:
240 error ../src/rpi-ws281x.cc:229:5: error: ‘GetFunction’ was not declared in this scope
240 error      GetFunction(Nan::New<FunctionTemplate>(init)).ToLocalChecked());
240 error      ^~~~~~~~~~~
240 error ../src/rpi-ws281x.cc:229:5: note: suggested alternative:
240 error In file included from ../../nan/nan.h:286,
240 error                  from ../src/rpi-ws281x.cc:1:
240 error ../../nan/nan_maybe_43_inl.h:66:33: note:   ‘Nan::GetFunction’
240 error  inline MaybeLocal<v8::Function> GetFunction(
240 error                                  ^~~~~~~~~~~
240 error ../src/rpi-ws281x.cc:232:44: error: ‘setBrightness’ was not declared in this scope
240 error      GetFunction(Nan::New<FunctionTemplate>(setBrightness)).ToLocalChecked());
240 error                                             ^~~~~~~~~~~~~
240 error ../src/rpi-ws281x.cc:235:44: error: ‘reset’ was not declared in this scope
240 error      GetFunction(Nan::New<FunctionTemplate>(reset)).ToLocalChecked());
240 error                                             ^~~~~
240 error ../src/rpi-ws281x.cc:235:44: note: suggested alternative: ‘tzset’
240 error      GetFunction(Nan::New<FunctionTemplate>(reset)).ToLocalChecked());
240 error                                             ^~~~~
240 error                                             tzset
240 error In file included from ../../nan/nan.h:58,
240 error                  from ../src/rpi-ws281x.cc:1:
240 error ../src/rpi-ws281x.cc: At global scope:
240 error /home/pi/.cache/node-gyp/14.17.0/include/node/node.h:758: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]
240 error        (node::addon_register_func) (regfunc),                          \
240 error                                            ^
240 error /home/pi/.cache/node-gyp/14.17.0/include/node/node.h:792:3: note: in expansion of macro ‘NODE_MODULE_X’
240 error    NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
240 error    ^~~~~~~~~~~~~
240 error ../src/rpi-ws281x.cc:244:1: note: in expansion of macro ‘NODE_MODULE’
240 error  NODE_MODULE(addon, InitAll)
240 error  ^~~~~~~~~~~
240 error make: *** [rpi_ws281x.target.mk:114: Release/obj.target/rpi_ws281x/src/rpi-ws281x.o] Error 1
240 error gyp ERR! build error
240 error gyp ERR! stack Error: `make` failed with exit code: 2
240 error gyp ERR! stack     at ChildProcess.onExit (/home/pi/ext_nisa/node_modules/node-gyp/lib/build.js:194:23)
240 error gyp ERR! stack     at ChildProcess.emit (events.js:376:20)
240 error gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
240 error gyp ERR! System Linux 5.10.17-v7l+
240 error gyp ERR! command "/usr/bin/node" "/home/pi/ext_nisa/node_modules/.bin/node-gyp" "rebuild" "-j4" "--release"
240 error gyp ERR! cwd /home/pi/ext_nisa/node_modules/rpi-ws281x-native
240 error gyp ERR! node -v v14.17.0
240 error gyp ERR! node-gyp -v v7.1.2
240 error gyp ERR! not ok

I think i fixed it, the question is how did it work at all before? This is the diff:

diff --git a/src/rpi-ws281x.cc b/src/rpi-ws281x.cc
index f487b02..deaafba 100755
--- a/src/rpi-ws281x.cc
+++ b/src/rpi-ws281x.cc
@@ -226,19 +226,28 @@ void finalize(const Nan::FunctionCallbackInfo<v8::Value> &info) {
 
 NAN_MODULE_INIT(InitAll) {
   Nan::Set(target, Nan::New<String>("init").ToLocalChecked(),
-    GetFunction(Nan::New<FunctionTemplate>(init)).ToLocalChecked());
+    Nan::GetFunction(Nan::New<FunctionTemplate>(init)).ToLocalChecked());
 
-  Nan::Set(target, Nan::New<String>("setBrightness").ToLocalChecked(),
-    GetFunction(Nan::New<FunctionTemplate>(setBrightness)).ToLocalChecked());
+//  Nan::Set(target, Nan::New<String>("setBrightness").ToLocalChecked(),
+//    Nan::GetFunction(Nan::New<FunctionTemplate>(setBrightness)).ToLocalChecked());
 
-  Nan::Set(target, Nan::New<String>("reset").ToLocalChecked(),
-    GetFunction(Nan::New<FunctionTemplate>(reset)).ToLocalChecked());
+  Nan::Set(target, Nan::New<String>("setParam").ToLocalChecked(),
+    Nan::GetFunction(Nan::New<FunctionTemplate>(setParam)).ToLocalChecked());
+
+  Nan::Set(target, Nan::New<String>("setChannelParam").ToLocalChecked(),
+    Nan::GetFunction(Nan::New<FunctionTemplate>(setChannelParam)).ToLocalChecked());
+
+  Nan::Set(target, Nan::New<String>("setChannelData").ToLocalChecked(),
+    Nan::GetFunction(Nan::New<FunctionTemplate>(setChannelData)).ToLocalChecked());
+
+ // Nan::Set(target, Nan::New<String>("reset").ToLocalChecked(),
+//    Nan::GetFunction(Nan::New<FunctionTemplate>(reset)).ToLocalChecked());
 
   Nan::Set(target, Nan::New<String>("render").ToLocalChecked(),
-    GetFunction(Nan::New<FunctionTemplate>(render)).ToLocalChecked());
+    Nan::GetFunction(Nan::New<FunctionTemplate>(render)).ToLocalChecked());
 
   Nan::Set(target, Nan::New<String>("finalize").ToLocalChecked(),
-    GetFunction(Nan::New<FunctionTemplate>(finalize)).ToLocalChecked());
+    Nan::GetFunction(Nan::New<FunctionTemplate>(finalize)).ToLocalChecked());
 }
 
 NODE_MODULE(addon, InitAll)

So GetFunction needed the Nan:: namespace, makes sense.

But some bindings where pointing to non-existing functions (reset and setbrightness), while others where missing. (set*)

Now it compiles and functions in my setup. (raspbian 10 on pi zero with nodejs 14)

Any news? I need to run this on a RPI 3B+

Thanks for your reply @SimonGAndrews

I’ve used NVM to switch to use node 10.21.0 and npm installed the rpi-ws281x package, however it seems running the test I get the same type of error as I did with this ws281x-native:

internal/modules/cjs/loader.js:1208
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '/home/pi/test/node_modules/rpi-ws281x/build/Release/rpi-ws281x.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1208:18)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/home/pi/test/node_modules/rpi-ws281x/index.js:2:13)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)

Try my fork, I used to have similar issues. https://github.com/lubomirmolin/rpi-ws281x-nodejs