wilix-team / iohook

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

Cannot find module 'iohook' during installation #334

Closed callejoadrian closed 3 years ago

callejoadrian 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 appear...

Capture123

If I remove the iohook in my program, the installation is successful and this message does not appear.

Expected Behavior

No problem on installation and iohook is working.

Current Behavior

error while installing the program

Possible Solution

Steps to Reproduce (for bugs)

  1. I manually add the binary file in my nodes_modules/iohook/builds folder
  2. npm run make (I used electron forge)
  3. go to /out/make/squirrel.windows/x64/file.exe
  4. install the .exe file

Context

Your Environment

image

marcelblum commented 3 years ago

Did you check to see if the iohook binaries actually got installed in the install path (...\resources\app\node_modules\iohook\builds...)? If not then you probably just need to tweak your forge config. Are you using ASAR?

callejoadrian commented 3 years ago

@marcelblum hi good day! btw i forgot to mention that iohook folder is missing in the install path. sorry I'm new in electron/node. how/what im going to update in my forge config? and probably, Im not using ASAR. thanks for the reply.

marcelblum commented 3 years ago

Is iohook listed in your package.json under dependencies?

callejoadrian commented 3 years ago

image

these are my dependencies. I also tried to add "iohook": "^0.9.1"

but an error occur when i tried to compile it.

marcelblum commented 3 years ago

Ok so sounds like since you compiled it yourself, you just manually placed a iohook folder in your node_modules and never did a npm install iohook. Forge definitely won't automagically know to include iohook in your packaged app since it's not listed in your dependencies. I think the easiest thing for you to do would be to create another node_modules folder inside your /src/ folder and move your custom iohook folder inside that /src/node_modules. That way it should be automatically included in your app package by Forge as part of your app's source code, and then it should be automatically found by your app when it does a require('iohook') because require will search that relative node_modules path for it.

Alternatively, you can use the extraResource option in your Forge packager config to specify that the iohook folder be copied over during the packaging process.

callejoadrian commented 3 years ago

Yes. i just copy and paste the iohook binary file since npm install iohook is not working.

_create another node_modules folder inside your /src/ folder and move your custom iohook folder inside that /src/nodemodules

this directions works for me. thanks for the help @marcelblum.

ash0x0 commented 3 years ago

@callejoadrian why is npm install iohook not working for you?

callejoadrian commented 3 years ago

@ash0x0 I just tried it today. now its all working. but last time(maybe last 2 weeks?) I cannot download the package and it returns an 404 error message.

callejoadrian commented 3 years ago

@ash0x0 thank you so much for the updates.