node.jselectronelectron-rebuild

serialport for electron NODE_MODULE_VERSION error and rebuild does not fix


OS: win 10 Node.js : v12.18.3 electron: v10.1.1

print version from js program: process.versions.node 12.16.3 process.versions.modules 82

  1. install serialport by: npm install serialport

  2. npm start and get error:

Error: The module '\?\D:\node\Tester\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 82. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install).

  1. npm install --save-dev electron-rebuild .\node_modules.bin\electron-rebuild

Rebuild Complete

  1. npm start and the error again.

Error: The module '\?\D:\node\Tester\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 82. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install).

What should be noticed is, both v12.18.3 and 12.16.3 has NODE_MODULE_VERSION 72. and no version gets 82. I don't know where the '82' comes from. How can I sovle it? Thanks.


Solution

  • I had the same issue this morning. With over 5 hours of troubleshooting the only thing that worked for me was to downgrade electron-rebuild to v2.0.1. I am using node v14.9.0(latest), electron v10.1.1(latest), serialport v9.0.1(latest)

    Looks like they have an issue open: https://github.com/electron/electron-rebuild/issues/404