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
ornpm install
)
I did try to use electron-rebuild
as described in the nodejs documentation but the error still exits.
Anyone know what to do?
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:
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:
that you can compare with your current version of Node.js.
I solved that exactly same error with the use of electron-rebuild:
You could add a "postinstall" script with this command in your
package.json
to automate the process.