octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.4k stars 970 forks source link

I cannot use RobotJS in my ElectronJS project #732

Open devliberte opened 1 year ago

devliberte commented 1 year ago

Link to the project where I received an error: https://github.com/devliberte/electronrobotjs I am trying to include the RobotJS library in my ElectronJS project. I have done everything as it should be and started the project. However, when I click the button, it gives an error. What could be the source of the problem? I would appreciate it if you could help me. gataso n

mankeheaven commented 1 year ago

if you use webpack, you can externals it as commonjs

devliberte commented 1 year ago

if you use webpack, you can externals it as commonjs I could not fully understand. Can you elaborate a little more?

s1hofmann commented 1 year ago

Given the error message and the fact that the repo you linked is just a plain Electron project without any bundler I’d simply assume that the robotjs build process failed.

The error message tells you that it can’t locate a robotjs.node bindings file, and since there are no prebuilds for robotjs, this bindings file would’ve to be built on your machine. If it fails, you can’t use it.

LiuZhenyan-Wuzhong commented 1 year ago

Given the error message and the fact that the repo you linked is just a plain Electron project without any bundler I’d simply assume that the robotjs build process failed.

The error message tells you that it can’t locate a robotjs.node bindings file, and since there are no prebuilds for robotjs, this bindings file would’ve to be built on your machine. If it fails, you can’t use it.

Yes, there is no target file where the prebuild-install requests.

prebuild-install http request GET https://github.com/octalmage/robotjs/releases/download/v0.6.0/robotjs-v0.6.0-electron-v110-win32-x64.tar.gz
    prebuild-install http 404 https://github.com/octalmage/robotjs/releases/download/v0.6.0/robotjs-v0.6.0-electron-v110-win32-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=22.3.2 runtime=electron arch=x64 
libc= platform=win32)
s1hofmann commented 1 year ago

@LiuZhenyan-Wuzhong Yes, the 0.6.0 release is broken and does not provide prebuilds for all platforms.

robotjs should actually compile bindings itself on install, so you also have to make sure to have the required toolchain installed on your system (if you want to distribute your app on other platforms as well you have to take care about that as well).

Did you receive any error messages on install?

Alternatively, you can give https://github.com/nut-tree/nut.js a try. It’s fully prebuilt for all platforms.