When using Electron 5 with Serialport 7.1.5 I am getting the following error.
I have a postinstall task that runs electron-builder install-app-deps.
As far as I know, this should re-compile the native dependencies against the appropriate Electron version.
When using Electron 4, it's working without any issues.
App threw an error during load
Error: The module '/Users/Client/node_modules/@serialport/bindings/build/Release/bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 47. This version of Node.js requires
NODE_MODULE_VERSION 70. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.func [as dlopen] (electron/js2c/asar.js:155:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:850:18)
at Object.func [as .node] (electron/js2c/asar.js:155:31)
at Module.load (internal/modules/cjs/loader.js:677:32)
at tryModuleLoad (internal/modules/cjs/loader.js:609:12)
at Function.Module._load (internal/modules/cjs/loader.js:601:3)
at Module.require (internal/modules/cjs/loader.js:715:19)
at require (internal/modules/cjs/helpers.js:14:16)
at bindings (/Users/Client/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/Users/Client/node_modules/@serialport/bindings/lib/darwin.js:1:36)
I am not sure, if this is a problem of Serialport or Electron or Electron-Bulider?
@phhoef try this :
https://github.com/song940/node-escpos/issues/214#issuecomment-502806807
It worked for me, but gave me a strange behavior after.
Thanks for your reply - but your answer also confuses me.
Ad far as I know, running electron-builder install-app-deps藡 should completely replace the 藡electron-rebuild藡.
Anyhow, I tried running 藡electron-rebuild藡, but with no success.
I'm experiencing the same issue. Did older versions work? I'm actually doing both because I didn't know what was necessary:
"postinstall": "yarn rebuild && electron-builder install-app-deps",
"rebuild": "electron-rebuild -f -o node-hid && electron-rebuild -f -o serialport",
Yes, my configuration is working, when using electron 4.
as mentioned, I have a postinstall task for rebuilding the native dependencies: electron-builder install-app-deps
I鈥榣l try your rebuild task, maybe this is working for me ...
The rebuild worked for me using node-hid but doesn't seem to work for this library:

Same here, rebuild does not work for serialport. :-(
I also encountered the same problem, using the latest version of electronic (5.0.4) node (12.4.0), serialport (7.1.5), and electronic back to 4.2.4.
MedAmineBenyettou comment solution worked for me. Rebuild worked for Zigbee.
./node_modules/.bin/electron-rebuild appended at the run script will work. This is not the permanent solution but a fix and will work for now.
I also encountered this problem, it still doesn't work in all solution above.
the same problem
I also encountered the similar issue when I want to create a vscode plugin with serialport.
My env:
windows 10 x64
serialport: 7.1.5
nodejs: 12.7.0
Activating extension undefined_publisher.helloworld failed: The module '\?\f:\tool_developer\vscode\helloworld\node_modules\@serialport\bindings\build\Release\bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 69. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).
If I change the nodejs version to 10.11.0, also has this issue. But the error information is different:
Activating extension undefined_publisher.helloworld failed: The module '\?\f:\tool_developer\vscode\helloworld\node_modules\@serialport\bindings\build\Release\bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 69. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).
Hi guys, I have fixed this issue: use serialport in vscode plugin.
steps:
install serialport
npm install serialport
rebuild
./node_modules/.bin/electron-rebuild --version 4.2.7
NOTE: 4.2.7 is electron version, perhaps you need to change for different vscode version.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week no further activity occurs. Feel free continue the discussion or ask for a never-stale label to keep it open. If this is a support issue, consider sharing it on stack overflow to get more eyes on your problem.
Most helpful comment
Hi guys, I have fixed this issue: use serialport in vscode plugin.
steps:
npm install --save-dev electron-rebuild
install serialport
npm install serialport
rebuild
./node_modules/.bin/electron-rebuild --version 4.2.7
NOTE: 4.2.7 is electron version, perhaps you need to change for different vscode version.