Code Monkey home page Code Monkey logo

Comments (54)

joglabsdotcom avatar joglabsdotcom commented on August 20, 2024 4

Try this.
https://www.youtube.com/watch?v=6o9xybTYlLU

For audio : https://app.box.com/s/6gusokl3srmj85iyohavoyjvwmesfapg

from iohook.

inomdzhon avatar inomdzhon commented on August 20, 2024 3

Hm, it's simple to solve.

For example, if you have error like this

Error: Cannot find module '../node_modules/iohook/builds/electron-v75-darwin-x64/build/Release/iohook.node'

See part of error message electron-v75-darwin-x64, put their to package.json

  "iohook": {
    "targets": [
      "electron-75"
    ],
    "platforms": [
      "darwin"
    ],
    "arches": [
      "x64"
    ]
  }

and install iohook again

npm i -S iohook

That it's.

Work for me.

from iohook.

apodolny avatar apodolny commented on August 20, 2024 2

A note to anyone installing with Yarn: be sure to remove iohook from your global cache before reinstalling or you won't end up with the builds for the environments that you've added.

yarn cache clean iohook

from iohook.

Djiit avatar Djiit commented on August 20, 2024 1

Hi there,

Did you add the 'iohook' config in your package.json ? According to your env, i'll say :

"iohook": {
  "targets": [
    "node-59",
    "electron-54"
  ],
  "platforms": [
    "win32",
    "darwin"
  ],
  "arches": [
    "x64",
    "ia32"
  ]
}

And then re-download your dependencies; this way it will fetch prebuild versions of iohook for node (the one you use in development and when using electron . AND for electron (the one you are supposed to use in production.

from iohook.

egantz avatar egantz commented on August 20, 2024 1

Hi Djiit! Thanks so much for the quick reply. yeah I def did it and actually added all the electron versions available since I get an error when I don't do it. my ioHook config in my package.json looks like this:

"iohook": {
    "targets": [
      "node-59",
      "electron-47",
      "electron-54",
      "electron-57"
    ],
    "platforms": [
      "win32",
      "darwin"
    ],
    "arches": [
      "x64",
      "ia32"
    ]
  }

Then, I am running yarn add ioHook to re-fetch the binaries.

But, still as soon as I try to compile the app and run the result - I get the same error that the ioHook library is missing.

from iohook.

egantz avatar egantz commented on August 20, 2024 1

Hi @Djiit ,

I actually referred to the yarn run build command which packs the app. I tried now to get rid of the --asar flag from the electron-packager command so the library won't make an archive file from the source code. that actually solved the problem! and my app works just fine. BUT! I do want to "hide" my code inside an archive file. so I assume once the app is in an archive, it can't find the ioHook library.

Any ideas? I am digging into it now and will come back with updates.

from iohook.

felipe-augusto avatar felipe-augusto commented on August 20, 2024 1

@zxc23 thank you for your reply, I was able to find the solution, I was using the latest electron version, but it seems, for now, it is only supported on 8.x.x, this comment here explains basically everything you need to do:

#241 (comment)

from iohook.

Djiit avatar Djiit commented on August 20, 2024

That is weird. What is the error you get when you don't add "all the electron versions" ?

from iohook.

egantz avatar egantz commented on August 20, 2024

that the electron version is missing and I need to install it, every time it shows about a different version

from iohook.

Djiit avatar Djiit commented on August 20, 2024

You should only have one electron target, the one corresponding to your current electron version. Can you copy/paste your results here ?

from iohook.

egantz avatar egantz commented on August 20, 2024

Hi @Djiit thanks for the quick reply and sorry for my late response - I was busy with holiday times :)

So I did what you just told me to do (I am running NodeJS 9.2.0 so I am using build 59 and Electron 1.7.0 so I'm using build 57) I left only these two in the package.json file as you said.

I have packed the app using electron-packager, it packed the app successfully and as soon as I try to run the packed app I get this window:
image

Both in Windows and Mac.

Any ideas why does it happen?

from iohook.

egantz avatar egantz commented on August 20, 2024

@Djiit help? πŸ™πŸ»

from iohook.

Djiit avatar Djiit commented on August 20, 2024

Are you sure the prebuild version are presents in node_module/iohook ?
Also can you try to make a minimal app to reproduce the problem ? (i.e. electron and iohook only)

from iohook.

egantz avatar egantz commented on August 20, 2024

Hi, @Djiit sorry for the late response.

  1. Yeah, it seems like the prebuild versions are there, under node_modules/iohook/builds:
    image

and then each build has folders: builds/Release/iohook.node

  1. Yeah, I just created a minimal side-project to see if it happens there and it doesn't! So I went back to my app, updated the library from 1.3 to 1.5, updated electron to 1.8.4 and nodeJS to 9.2.0, went to the package.json file and set the electronVersion to 1.8.4, the targets are electron-57 and node-59, tried to run yarn run build --overwrite, then run the result on my mac and the same thing, tried with windows - same thing:
    image

I have a single file that requires electron and iohook, watching the mouseclick event to do a simple thing. can't see anything that could cause the problem.

any ideas?

from iohook.

Djiit avatar Djiit commented on August 20, 2024

Well, that's weird.
Would you mind granting me a read-only access to your repository ? I think I'll have a couple hours free this weekend to check it out.

You shouldn't have to build anything as you are on macOS and we provide prebuilt binaries...

from iohook.

matthewshirley avatar matthewshirley commented on August 20, 2024

electron-rebuild sometimes fixes these issues. https://github.com/electron/electron-rebuild

from iohook.

egantz avatar egantz commented on August 20, 2024

@Djiit : I will push this project to a private repo and will invite you to it. many thanks, man! I am not building anything that is related to iohook, when I said "build" I referred to package the electron app with electron-packager

@matthewshirley Ok, tried to use this library - I added it to my project, then from the terminal I exected ./node_modules/.bin/electron-rebuild successfully, then tried to use electron-packager again and the result still the same. I am just using the electron-packager directly from the CLI, under the scripts property in my package.json file I have:
"build": "electron-packager . $npm_package_productName --out=dist --ignore='^/dist$' --prune --asar --all --version=$npm_package_electronVersion"

what do I do wrong here?

from iohook.

matthewshirley avatar matthewshirley commented on August 20, 2024

Is electron included as a dependency in your package.json?

from iohook.

egantz avatar egantz commented on August 20, 2024

@matthewshirley only in devDependencies: "electron": "^1.8.4",

from iohook.

matthewshirley avatar matthewshirley commented on August 20, 2024

Do you have electron-rebuild installed globally or locally? If locally, run the command:

./node_modules/.bin/electron-rebuild -f iohook

from iohook.

egantz avatar egantz commented on August 20, 2024

@matthewshirley doesn't help :(

from iohook.

egantz avatar egantz commented on August 20, 2024

@Djiit Hi! sorry for the delay - added you yesterday as a contributor to the repo

from iohook.

Djiit avatar Djiit commented on August 20, 2024

Hey @egantz !

So I cloned our repository, I ran yarn and then yarn start : your app was working like a charm, printing the pressed mouse button in the terminal.

Note that I had to remove some lines (condition regarding the log level of the app) to make it work; but this is in no way related to ioHook.

I'm on a up-to-date 2013 MacBook Pro.

from iohook.

Djiit avatar Djiit commented on August 20, 2024

I tried to drop the --asar flag but it still doesn't work here. So strange :(

from iohook.

egantz avatar egantz commented on August 20, 2024

really? ok so it works but I really want to use the asar in order to get to an archive file instead of the source files to be exposed. I will try to dig more into their documentation and will send some updates here

from iohook.

egantz avatar egantz commented on August 20, 2024

Hi, now Windows' giving me hard times - Error: %1 is not a valid Win32 application. \\?\C:\Windows\Help\log-analysis-win32-ia32\resources\app\node_modules\iohook\builds\electron-v57-win32-ia32\build\Release\iohook.node

Any ideas? I see the file but it says it's invalid for some reason.

from iohook.

Djiit avatar Djiit commented on August 20, 2024

What did you change in your code or configuration ?

from iohook.

egantz avatar egantz commented on August 20, 2024

nothing that was really related to the library itself. but I finally managed to pack the app, and tried to run it on windows x64 for the first time - and bumped into this error.

from iohook.

Djiit avatar Djiit commented on August 20, 2024

Hi there, any news on this ?

from iohook.

egantz avatar egantz commented on August 20, 2024

Hi @Djiit, thanks for the follow up. We ditched this project for now, so I never got any updates about that. If we'll get back to it. I will drop here any updates we'll have. Thanks again!

from iohook.

Djiit avatar Djiit commented on August 20, 2024

Thanks for the feedback, I'm closing this now, feel free to comment here in the future and we'll reopen it.

from iohook.

tbs-arpit avatar tbs-arpit commented on August 20, 2024

Facing this
Screen grab is from dev tools of electron app

image

Here is my package.json

Package.json

{
  "name": "<Project name :P>",
  "version": "1.19.0",
  "description": "A simple electron app for <project name :P>",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "electron main.js",
    "setup": "node build.js",
    "icon": "node icon.js"
  },
  "repository": {
    "type": "git",
    "url": "<Project URL>"
  },
  "iohook": {
    "targets": [
      "node-59",
      "electron-54"
    ],
    "platforms": [
      "win32",
      "darwin"
    ],
    "arches": [
      "x64",
      "ia32"
    ]
  },
  "cmake-js": {
    "runtime": "electron",
    "runtimeVersion": "1.4.13"
  },
  "keywords": [
    "electron",
    "windows",
    "mac"
  ],
  "author": "Arpit Vasani",
  "license": "ISC",
  "devDependencies": {
    "asar": "^0.14.0",
    "electron": "^1.7.10",
    "electron-installer-dmg": "^0.2.1",
    "electron-installer-windows": "*",
    "electron-packager": "^10.1.1",
    "electron-winstaller": "^2.6.3"
  },
  "dependencies": {
    "aws-sdk": "^2.340.0",
    "electron-rebuild": "^1.8.2",
    "electron-squirrel-startup": "^1.0.0",
    "iohook": "^0.3.1",
    "network": "^0.4.0",
    "util": "^0.11.1"
  }
}

from iohook.

vasani-arpit avatar vasani-arpit commented on August 20, 2024

Nice video. Thanks for taking efforts for it.

from iohook.

joglabsdotcom avatar joglabsdotcom commented on August 20, 2024

Nice video. Thanks for taking efforts for it.

Welcome!

Lots of Thanks to iohook team for making such an awesome module.

from iohook.

chad187 avatar chad187 commented on August 20, 2024

Thanks for the feedback, I'm closing this now, feel free to comment here in the future and we'll reopen it.

@Djiit I didn't see any resolution

from iohook.

chad187 avatar chad187 commented on August 20, 2024

Hi @Djiit ,

I actually referred to the yarn run build command which packs the app. I tried now to get rid of the --asar flag from the electron-packager command so the library won't make an archive file from the source code. that actually solved the problem! and my app works just fine. BUT! I do want to "hide" my code inside an archive file. so I assume once the app is in an archive, it can't find the ioHook library.

Any ideas? I am digging into it now and will come back with updates.

@egantz this is exactly the problem I am still stuck on. Please reopen the issue.

from iohook.

chad187 avatar chad187 commented on August 20, 2024

Hi @Djiit ,

I actually referred to the yarn run build command which packs the app. I tried now to get rid of the --asar flag from the electron-packager command so the library won't make an archive file from the source code. that actually solved the problem! and my app works just fine. BUT! I do want to "hide" my code inside an archive file. so I assume once the app is in an archive, it can't find the ioHook library.

Any ideas? I am digging into it now and will come back with updates.

I also found it to work without asar and fail with asar. So I ran asar with iohook unpackaged and I got this error
Capture
those files are included in the unpackaged folder

!!update it is working on a different computer and a build from Travis CI. I believe the issue lies with visual c++ build tools

from iohook.

zxc23 avatar zxc23 commented on August 20, 2024

Experiencing the above on some PCs and not others. Quite weird. They are all Win32 x64 PCs.

error

from iohook.

taoabc avatar taoabc commented on August 20, 2024

Same issue here, works well with folder. BUT, when I pack folder to asar, and run from asar, it gives me message: xxx.tmp.node could not be found. when I extract the same app.asar to app folder, it works.

from iohook.

taoabc avatar taoabc commented on August 20, 2024

I think the issues is caused by dependency of uiohook.dll, electron could recognize .node file, and extract it to temp folder, then change require path to temp .node path internally, but It can't extract dll files.
I suggest compile uiohook to iohook.node with static link, not dynamic link.
Or do not pack it to asar, just folder.

from iohook.

zxc23 avatar zxc23 commented on August 20, 2024

After installing my application, I've noticed that resources/ has app.asar.unpacked which contains node_modules/iohook/. It looks like on installation, iohook is unpacked from the asar (I guess it needs to be in order to be used properly?). But on some computers, the electron application can't locate the unpacked iohook.node file, which in my case would be located in resources\app.asar.unpacked\node_modules\iohook\builds\electron-v70-win32-x64\build\Release

from iohook.

woniesong92 avatar woniesong92 commented on August 20, 2024

I face the same issue on a fresh electron quickstart app.

Reproduction steps:

$ git clone https://github.com/electron/electron-quick-start
# Go into the repository
$ cd electron-quick-start
# Install dependencies
$ yarn
# Run the app
$ yarn start
# Add iohook
$ yarn add iohook
# Require it in main.js

main.js

const ioHook = require("iohook");
ioHook.on("keyup", event => {
  console.log(event); // {keychar: 'f', keycode: 19, rawcode: 15, type: 'keup'}
});
ioHook.start();

error

App threw an error during load
Error: Cannot find module '/Users/d/tmp/electron-quick-start/node_modules/iohook/builds/electron-v75-darwin-x64/build/Release/iohook.node'
Require stack:
- /Users/d/tmp/electron-quick-start/node_modules/iohook/index.js
- /Users/d/tmp/electron-quick-start/main.js
- /Users/d/tmp/electron-quick-start/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js
-
    at Module._resolveFilename (internal/modules/cjs/loader.js:717:15)
    at Function../lib/common/reset-search-paths.ts.Module._resolveFilename (electron/js2c/browser_init.js:7613:16)
    at Module._load (internal/modules/cjs/loader.js:622:27)
    at Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (electron/js2c/asar.js:717:26)
    at Module.require (internal/modules/cjs/loader.js:775:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/Users/d/tmp/electron-quick-start/node_modules/iohook/index.js:10:21)
    at Module._compile (internal/modules/cjs/loader.js:880:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:892:10)

from iohook.

nolior avatar nolior commented on August 20, 2024

I'm running into the same issue ^

from iohook.

m1n0s avatar m1n0s commented on August 20, 2024

I've faced this issue as well on my end and no matter what I'm trying from the advices from this issue - neither yarn nor npm can download proper node binding.

package.json

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

But inside node_modules I can see only 1 binding probably based on my mac host env.
image

I've tried to clean caches, reinstall all modules with both yarn and npm and nothing helped and I still have Error: Cannot find module '/Users/leontii.hrabovetskyi/Projects/desktop-communicator/node_modules/iohook/builds/electron-v76-darwin-x64/build/Release/iohook.node'

Any further advices please? I can download electron-v76-darwin-x64 manually and place it inside a folder from screenshot above but this doesn't work for CI obviously.

EDIT: Not sure how this helped but I succeeded to get all needed files after added asarUnpack value under build in package.json.

"build": {
    "asarUnpack": "**/*.node"
}

image

from iohook.

felipe-augusto avatar felipe-augusto commented on August 20, 2024

I'm having the same problem:

Cannot find module '/Users/myuser/apps/myproject/node_modules/electron/dist/
Electron.app/Contents/Resources/electron.asar/renderer/
builds/electron-v80-darwin-x64/build/Release/iohook.node'

And the file exists inside the node_modules/iohook folder:

image

Any ideas?

from iohook.

zxc23 avatar zxc23 commented on August 20, 2024

Looks like I forgot to reference and post in this issue.

An update: I've had multiple confirmations that this problem was resolved by installing Microsoft Visual C++ Redistributable on the machines via https://support.microsoft.com/en-au/help/2977003/the-latest-supported-visual-c-downloads.

These issues are all related:

#55
#167
#193
#195
#224
#245

from iohook.

felipe-augusto avatar felipe-augusto commented on August 20, 2024

@zxc23 actually I'm not on windows, I don't think that solves my problem :(

from iohook.

zxc23 avatar zxc23 commented on August 20, 2024

@felipe-augusto Oh, that's too bad, I have no ideas. I had the problem on Windows 10 machines and this was the only solution which worked for them.

from iohook.

danikoala avatar danikoala commented on August 20, 2024

Can we have a solution for Electron 9.x.x??

from iohook.

bgsuello avatar bgsuello commented on August 20, 2024

If you are using two package.json structure with electron-builder, just add iohook in your app/package.json.

works on:
Electron React Boilerplate v1.3.0
Node v12.13.0 (abi: 72)
Electron v8.4.3 (abi: 76)

from iohook.

gelpiu-developers avatar gelpiu-developers commented on August 20, 2024

Same behaviour in Electron 11

from iohook.

lmr520 avatar lmr520 commented on August 20, 2024

@zxc23 thank you for your reply, I was able to find the solution, I was using the latest electron version, but it seems, for now, it is only supported on 8.x.x, this comment here explains basically everything you need to do:

#241 (comment)

I change to 8.5.5 ,I added files to builds like ,what do more for it with you ? @felipe-augusto

ζˆͺ屏2021-05-25 δΈ‹εˆ2 30 08

from iohook.

ash0x0 avatar ash0x0 commented on August 20, 2024

Closing as irrelevant. This doesn't seem to be an issue anymore. Feel free to reopen with some more up-to-date info.

from iohook.

vimalAtLR avatar vimalAtLR commented on August 20, 2024

same error I'm getting in linux
please give me some solution

from iohook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.