Usage with Electron of latest J5 versions?

Author: PimentosoCreated Jun 6, 2023Updated Dec 21, 2023

Hello,

I maintain an Electron app that uses J5 to control an arduino board via usb. I need to upgrade the node version but the ancient Electron I'm using (9.x) is no good, so I need to upgrade it and it brings along J5+serialport as well.

But I keep getting the Loading non-context-aware native module in renderer error

Uncaught Error: Loading non-context-aware native module in renderer: '/xxx/electron-johnny-five-examples/1-led/node_modules/@serialport/bindings/build/Release/bindings.node'. See https://github.com/electron/electron/issues/18397.
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1812)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1199:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1812)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
    at Function.o._load (node:electron/js2c/renderer_init:33:356)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at bindings (/xxx/electron-johnny-five-examples/1-led/node_modules/bindings/bindings.js:112:48)

Which is raised by serialport, but a minimal app using Electron+serialport (no J5) works fine (Electron 17 and serialport 10.5.0) --> https://github.com/serialport/electron-serialport

Here is a minimal app using Electron+J5 demonstrating the error, if anyone wants to replicate https://files.catbox.moe/tlezc1.zip It's adapted from an example that can be found here https://github.com/sofroniewn/electron-johnny-five-examples (not maintained anymore)

The versions I'm aiming to upgrade are

  • node 18
  • electron 17
  • J5 2.1.0
  • serialport 10.5.0