node-libgpiod icon indicating copy to clipboard operation
node-libgpiod copied to clipboard

Incompatible with recent Electron (v35+) due to deprecated V8 API usage

Open LukasWestholt opened this issue 8 months ago • 1 comments

Hi,

I'm trying to use node-libgpiod in an [Electron](https://www.electronjs.org/) project (specifically the [MagicMirror²](https://github.com/MagicMirrorOrg/MagicMirror) platform). However, the rebuild using electron-rebuild fails due to incompatibilities with the latest Electron versions (v35+), which are built against a newer V8 engine.

Here's the relevant error from the build log:

error: no matching function for call to ‘v8::ScriptOrigin::ScriptOrigin(v8::Isolate*, v8::Local<v8::Value>&)’

This seems to stem from how Nan::ScriptOrigin is used in nan_scriptorigin.h. Electron v35 uses a version of V8 where some ScriptOrigin constructors have changed, and calls like:

v8::ScriptOrigin(v8::Isolate::GetCurrent(), name)

are no longer valid.

This results in node-gyp failing to build the module when called via electron-rebuild.


Steps to reproduce:

  1. Use latest Electron (e.g., v35.1.2).
  2. Add node-libgpiod as a dependency.
  3. Run npx electron-rebuild.
  4. Observe the build failure.

Environment:

  • Electron: 35.1.2
  • Node.js: Electron bundled version
  • OS: Debian 12 (Raspberry Pi)

Possible Solution:

Updating the native code to use the new v8::ScriptOrigin constructor with all required parameters (e.g., resource_name, line_offset, column_offset, etc.). Alternatively, conditionally compile based on V8 version or use N-API if feasible.

Let me know if I can help test a patch or provide more build logs.

Thanks for your work on this module!

LukasWestholt avatar May 04 '25 03:05 LukasWestholt

Hello @LukasWestholt , i just updated nan and bindings to node 22, build passes but didn't tested with electron. When you have time, please let me know if latest version (0.4.8) works.

sombriks avatar May 10 '25 21:05 sombriks