iohook icon indicating copy to clipboard operation
iohook copied to clipboard

Electron Build / Code coverage report Fails with IOHook v0.9.3

Open Antelope-IT opened this issue 4 years ago • 2 comments

Expected Behavior

Just upgraded an Electron project from iohook v0.7.2 to iohook v0.9.3. deleting the node_modules directory in the process and running npm i. I have iohook targets set in package.json to node-72, electron-85. When I run a node script to generate a unit test code coverage report I expect the tests to run. This worked when using iohook v0.7.2 and for many previous versions of iohook.

Current Behavior

After upgrading to v0.9.3 of iohook I can run the Electron application in debug mode but when I attempt to run a coverage report or build a release with electron-builder (which also runs coverage reports) I get the following error.

Error: The module '\?\C:<application>\node_modules\iohook\builds\node-v72-win32-x64\build\Release\iohook.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 87. This version of Node.js requires NODE_MODULE_VERSION 72. Please try re-compiling or re-installing

Possible Solution

Looks like there is a problem with the iohook prebuild package process - its selected the correct prebuilt (node-v72-...) and identified that its running in a node 12 environment "requires NODE_MODULE_VERSION 72" but something is telling it that this prebuilt package was built for electron 12. I will probably revert to iohook v0.7.2.

Your Environment

  • IOHook Version: v0.9.3
  • Electron Environment name and version (e.g. Chrome 39, node.js 5.4, electron 11.2): Node 12.18.3, Electron 11.4.7, Chromium 87.0.4280.141
  • Command line Node environment (running coverage reports etc): Node version 12.7.0
  • Operating System and version (desktop or mobile): Windows Desktop 10 21H1
  • Optional Link to your project:

Antelope-IT avatar Jun 22 '21 11:06 Antelope-IT

Does this issue happen in production when packing with builder or forge or any other solution? This is the same overall problem with the build system but maybe I can get a quick fix to it with the current system if I can isolate the exact issue.

ash0x0 avatar Jun 26 '21 15:06 ash0x0

I don't get the chance to test in production because the build pipeline fails at the unit test code coverage phase before it actually builds with electron-builder. The code coverage unit test runs under istanbul / node v12.7 (nyc mocha src/**/*.ts) it seems to me, from the error message that the prebuilt module although it has been selected correctly for the environment (node v12) with the correct name "node-v72....." it has actually been built for electron v12 (ABI 87) and not node v12 (ABI 72). We don't have electron v12 in our environment so I'm not sure where it would have got that from other than detecting it in the prebuilt module. I have run the app with iohook 0.9.3 in development through VSCode (electron . ) - electron v11.4.7 which is the closest I can get to running the app in production.

I suspect that if I configure the build pipeline to skip the code coverage/unit tests that it would build with iohook v0.9.3 and run in production because it would select the correct prebuilt module and incorporate that into the final production build and we know that module works in development running under electron. Unfortunately I've rolled back the project to iohook 0.7.2 (and it works again) so I'm not really in a position to test that hypothesis.

Antelope-IT avatar Jun 26 '21 16:06 Antelope-IT