1

I am trying to use the nodemodule easymidi which depends on the midi module in an electron app.

When I run npm start an error occurs:

Error: The module '/var/www/html/mdi/node_modules/midi/build/Release/midi.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 46. This version of Node.js requires NODE_MODULE_VERSION 73. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install)

I did try to use electron-rebuild as described in the nodejs documentation but the error still exits.

Anyone know what to do?

TGrif
  • 5,725
  • 9
  • 31
  • 52
John
  • 536
  • 6
  • 18

1 Answers1

1

Update (Dec 2019)

It seems that with the latest version of electron-builder (version 21.2.0), you can remove electron-rebuild dependency and simply add a "postinstall script" like that, according to the warning of electron-builder:

electron-rebuild not required if you use electron-builder (...)

To ensure your native dependencies are always matched electron version, simply add script "postinstall": "electron-builder install-app-deps" to your package.json.


Original answer

The problem occurs because electron uses its own Node.js instance, with another version.

You can see the Node ABI version used by electron with the command:

./node_modules/.bin/electron -a

that you can compare with your current version of Node.js.

I solved that exactly same error with the use of electron-rebuild:

npm install --save-dev electron-rebuild
./node_modules/.bin/electron-rebuild midi

You could add a "postinstall" script with this command in your package.json to automate the process.

TGrif
  • 5,725
  • 9
  • 31
  • 52