wilix-team / iohook

Node.js global keyboard and mouse listener.
https://wilix-team.github.io/iohook
MIT License
1.19k stars 292 forks source link

Can not find module iohook.node after installation .exe #359

Open geniusmonir opened 3 years ago

geniusmonir commented 3 years ago

iohook is working properly in my development platform. Compiling the program is also working. But when I tried to install the .exe file this error is appearing. I have manually build iohook for electron version 13. It is working fine during development. But after building this error is appearing. I have tried both with asar and without asar.

with asar without asar

May be if i am able to see the full directory where the app is requiring iohook.node then i can able to fix the issue but its /app.a.../iohook.node thats why i am unable to figure it out. Note: I have manually build iohook for electron version 13 and node version 14. With following setup. Its working fine during development seriously.

"iohook": { "targets": [ "node-83", "electron-89" ], "platforms": [ "win32", "darwin", "linux" ], "arches": [ "x64", "ia32" ] },

Expected Behavior

Should work fine as development.

Current Behavior

error while installing the program

Possible Solution

I have tried all possible solution mentioned on stackoverflow and some other places spending 8 hours. May be this is not a bug but a well documentation about implementation with webpack and electron builder may help us. Also a prebuilds update for electron v13 and v14 will be better.

Steps to Reproduce (for bugs)

  1. git clone https://github.com/electron-react-boilerplate/electron-react-boilerplate.git
  2. install iohook inside /src/ directory as mentioned in their documentation and try to do some basic implementation on main process
  3. Manually build prebuilds iohook for electron v13 and node v14.
  4. try to build by yarn package then install the installer.exe file.

Context

Your Environment

marcelblum commented 3 years ago

You can use require.resolve('iohook') to find out where the runtime is looking for the missing iohook.node file. Note that @ash0x0 has stated that it won't work in Electron 13 without significant modifications.

geniusmonir commented 3 years ago

You can use require.resolve('iohook') to find out where the runtime is looking for the missing iohook.node file. Note that @ash0x0 has stated that it won't work in Electron 13 without significant modifications.

Hi Thanks, May be i can be able to fix the issue but the problem is i am unable to get the package location of iohook.node. require.resolve('iohook') is returning path in development but its returning a number 78200 when i am in production. Can you please specify the working way of getting path in production?

marcelblum commented 3 years ago

Sorry you can try require.resolve.paths("iohook"). I don't know what 78200 could mean in this context but I see it also appears in your error screenshots above ("...at Object.78200"). I don't know where those error dialogs you screenshotted are coming from but they are obviously abbreviated in an unhelpful way so check the actual javascript console for the full error messages.

geniusmonir commented 3 years ago

Sorry you can try require.resolve.paths("iohook"). I don't know what 78200 could mean in this context but I see it also appears in your error screenshots above ("...at Object.78200"). I don't know where those error dialogs you screenshotted are coming from but they are obviously abbreviated in an unhelpful way so check the actual javascript console for the full error messages.

for this require.resolve.paths("iohook") ....paths is not a function in productions, But i got the alternative way to find out the path from where its requiring the module iohook.node and i have fixed that route inside index.js of iohook module thats also isn't working. the exact same path exists the iohook.node file but the app is saying can not find this module. I have also tried to manually change the location with the prebuilds thats also isn't working. Its pretty strange things that the exact path exists the *.node file but it says its can not find the module. may be @ash0x0 is right its need some significant change for working this module. This module is also not working in electron 12 with asar:true. asar must be false for working with it in electron 12. May be there are some significant changes required for electron 13/14. I am eagerly waiting for the update of iohook . I have spend two of my full working days on it (forgot to add timer) and i am unable to fix the issue. Thank you so much for your comment. Hope this will fix soon.

marcelblum commented 3 years ago

FWIW I have an Electron 12 project that uses iohook and asar:true successfully. I use Electron Forge for building and I make sure .node and .dll files are excluded from the asar. My forge config includes

asar: {
  unpack: "**/*.+(node|dll|exe)",
  smartUnpack: true
}

BTW if you're sure the .node file exists in your packaged app, also make sure the .dll is in the same path. If the dll is missing the error message will say "Cannot find module iohook.node" even if the .node file is there!

geniusmonir commented 3 years ago

FWIW I have an Electron 12 project that uses iohook and asar:true successfully. I use Electron Forge for building and I make sure .node and .dll files are excluded from the asar. My forge config includes

asar: {
  unpack: "**/*.+(node|dll|exe)",
  smartUnpack: true
}

BTW if you're sure the .node file exists in your packaged app, also make sure the .dll is in the same path. If the dll is missing the error message will say "Cannot find module iohook.node" even if the .node file is there!

Hey, Thanks for your time, I have cross checked there were both .dll and .node and did many possible ways to figure it out but failed. May be some other changes can fixes the issue. Hope this will be fixed by the team soon. And for Electron 11/12 i am using electron builder with asar:true and asarUnpack:"**/*.+(node|dll|exe)" but its failing. Its working perfect without asar enabled. I am interested and waiting for mejor changes in iohook that will support both electron 13 14. and node 16. as i am using this in a big project. Anyway i have downgraded my application electron version for iohook and will rebuild it after fixes of these issue. Thank you so much..

rupesh-10 commented 2 years ago

Hi @geniusmonir is this issue fixed ? I am also facing same kind of issue in electron 12 & node 16. image

geniusmonir commented 2 years ago

No the isssue is not fixed i used the earlier versions. without asar, asar:false

rupesh-10 commented 2 years ago

@geniusmonir which version of node, electron and iohook, can you please specify ?