iohook: iohook not found with Electron
Expected Behavior
iohook should work. Would like to use iohook in the front-end however cannot get it to work.
Current Behavior
Tried generating ABIs for both NodeJS and Electron and added sufficient parts to package.json. Have tried uninstalling, reinstalling, using https://www.electronjs.org/docs/tutorial/using-native-node-modules. Read multiple bug reports and articles and watched videos all to no avail. I believe it might be to do with Electron running a separate runtime version, however I’ve even tried editing the code to require the file by its absolute path and that still does not work.
Possible Solution
Steps to Reproduce (for bugs)
- Install iohook using NPM (
npm i iohook -s) - Run Electron (
electron .)
const electron = require('electron'),
iohook = require('iohook');
Context
Trying to do keystroke and mouse detection for an on-screen counter in Electron.
Your Environment
- Version used: v0.6.6
- Environment name and version (e.g. Chrome 39, node.js 5.4): Node.JS v11.10.1; Electron v9.1.0
- Operating System and version (desktop or mobile): Desktop (Windows 10)
- package.json:
"iohook": {
"targets": [
"node-67",
"electron-80"
],
"platforms": [
"win32",
"darwin",
"linux"
],
"arches": [
"x64",
"ia32"
]
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (3 by maintainers)
I am using node 12.13.0, iohook 0.6.6 and electron 8.3.4 on windows and doesn’t work, I get the same error saying the module was not found even the module is there. I tried adding the targets to my package json and still doesn’t work.
Any idea why it doesn’t work?
For Electron 8.3.4 your package json should now have
"targets": [ "electron-76", "node-72" ]for Electron 8 and Node 12. Node 12.13.0 is the one paired with Electron 8.3.4. Unless you are intentionally using a different Node version with your Electron setup (you mentioned Node.JS v11.10.1 above)?