Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run robotjs with electon: The module was compiled against a different Node.js version #646

Open
Viiprogrammer opened this issue Feb 15, 2021 · 6 comments

Comments

@Viiprogrammer
Copy link

If i runing electon app with RobotJS, throw error:

Error: The module '\\?\C:\Users\Maxim\node_modules\robotjs\build\Release\robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 85. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1812)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1203:18)
    at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1812)
    at Module.load (internal/modules/cjs/loader.js:992:32)
    at Module._load (internal/modules/cjs/loader.js:885:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
    at Module.require (internal/modules/cjs/loader.js:1032:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\Maxim\node_modules\robotjs\index.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:1152:30)

I try to run npm rebuild --runtime=electron --target=11.2.3 --disturl=https://atom.io/download/atom-shell --abi=72 and rebuilding successfuly, but dosen't work.

Environment

  • RobotJS version: 6.0.0
  • Electron version: 11.2.3
  • Electron Node.js version 12.18.3
  • Node.js version: v12.20.1
  • npm version: 6.14.10
  • Operating System: Windows 7 (also tried on Windows 10)

111
1111

@GDur
Copy link

GDur commented Feb 15, 2021

Others and me had the same problem and this helped:
#466 (comment)

Would be cool though if they fixed the underlying problem, so that we don't have to recompile. (But maybe the problem is on electrons side)

@xujingzhou
Copy link

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

@cliqer
Copy link

cliqer commented Apr 8, 2021

Use electron-builder and add in your package.json scripts section:
"postinstall": "electron-builder install-app-deps"

Each time you run yarn it will re-compile to the electron version you have installed.

@msynk
Copy link

msynk commented Sep 21, 2021

it is because all native node modules need a rebuild for electron as described here:
https://www.electronjs.org/docs/tutorial/using-native-node-modules

@fangjiapeng
Copy link

fangjiapeng commented Nov 18, 2021

Not only robojs, when I use node-pty, I got this error. The problem was resolved by using electron-rebuild:

scripts: {
  "rebuild-node-pty": "electron-rebuild -f -w node-pty"
}

run this command manually:
npm run rebuild-node-pty

same as node-pty:

scripts: {
  "rebuild-robojs": "electron-rebuild -f -w robojs"
}

@bbb169
Copy link

bbb169 commented Jan 25, 2024

I found another way to solve this
I found a fork of robotjs, and I use this library to replace robotjs, https://github.com/hurdlegroup/robotjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants