octalmage / robotjs

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

Re-building RobotJs for electron #675

Open coda-nsit opened 3 years ago

coda-nsit commented 3 years ago

I followed this and this link to make RobotJS work with electron. My electron version is 11.4.5. So I ran

npm rebuild --runtime=electron --target=11.4.5 --disturl=https://atom.io/download/atom-shell --abi=67

The above step successfully completes.

Then I run the integration test using Spectron (jest).

Expected Behavior

The integration test should run.

Current Behavior

I get the following error.

The module '/Users/.../node_modules/robotjs/build/Release/robotjs.node'was compiled against a different Node.js version using
NODE_MODULE_VERSION 85. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`).

Possible Solution

Maybe one of the solutions mentioned in this stackoverflow link. I have tried them but they don't seem to work either.

Steps to Reproduce (for bugs)

  1. npm i robotjs@0.6.0
  2. npm list | grep electron to check the electron version
  3. npm rebuild --runtime=electron --target=11.4.5 --disturl=https://atom.io/download/atom-shell --abi=67
  4. jest -i --detectOpenHandles

Context

Your Environment

wtesler commented 3 years ago

I also am unable to build for electron properly

gabrieldejesus commented 3 years ago

I'm also having the same error

wtesler commented 3 years ago

I fixed the error by running this after installing robotjs:

electron-rebuild -f -w robotjs

gabrieldejesus commented 3 years ago

I fixed the error by running this after installing robotjs:

electron-rebuild -f -w robotjs

I only managed to solve it by installing node again and checking an option that installs a tool with all the necessary tools.

VibingCreator commented 3 years ago

I would recommend checking this issue.

coda-nsit commented 3 years ago

I fixed the error by running this after installing robotjs:

electron-rebuild -f -w robotjs

@wtesler I just tried the command, doesn't seem to work 😩 I get the same error i.e.

 FAIL   shared  tst/app-launch.test.ts
  ● Test suite failed to run

    The module '/Users/..../node_modules/robotjs/build/Release/robotjs.node'
    was compiled against a different Node.js version using
    NODE_MODULE_VERSION 85. This version of Node.js requires
    NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
    the module (for instance, using `npm rebuild` or `npm install`).

      at Runtime._loadModule (node_modules/jest-runtime/build/index.js:893:29)
      at Object.<anonymous> (node_modules/robotjs/index.js:1:104)
coda-nsit commented 3 years ago

I fixed the error by running this after installing robotjs: electron-rebuild -f -w robotjs

I only managed to solve it by installing node again and checking an option that installs a tool with all the necessary tools.

Can you please elaborate a bit more?

s1hofmann commented 2 years ago

Maybe you want to give https://github.com/nut-tree/nut.js try. It’s an enhanced framework for desktop automation combining possibilities of robot-js with image matching via OpenCV which provides prebuilt binaries for several node and Electron versions.

It provides a nice API and additional features like highlighting desktop regions or retrieval of window coordinates / dimensions.

quinton-ashley commented 2 years ago

@s1hofmann Thank you! I had to drop robotjs support completely from my app cause I needed to build for the new arm Macs but robotjs wasn't compatible. Will def check nut.js out!

temberature commented 1 year ago

https://www.npmjs.com/package/@jitsi/robotjs has pre-build

liuyike98 commented 1 year ago

https://www.npmjs.com/package/@jitsi/robotjs has pre-build

great

river666 commented 1 year ago

@temberature @liuyike98 Thx so much!