Robotjs was used in the development of Electron, but it was found that it could not be installed successfully. The problem lies in the inconsistency between the robotJS version and the node version currently used in Electron. The solution is to recompile Electron and RobotJS using the same version. However, compiling RobotJS involves installing some other tools, which did not go so smoothly. Finally, it took several days to complete.

Environment and Version

  • windows 10
  • The node v14.10.0
  • Electron 10.1.5
  • Robotjs 0.6.0

Install RobotJS (run CMD with an administrator)

CNPM install robotJS — don’t worry about a series of errors reported during installation. Robotjs will be compiled after installation.

Recompile RobotJS (run CMD with an administrator)

  • Install the VS2013 build tool (Windows-build-tools)
  • Python v2.7.3 Note that 3.x is not supported
  • Installation node – gyp

Install the VS2013 build tool (Windows-build-tools)

cnpm install -g --production windows-build-tools

  • If the installation fails, you can manually log in to the current user directoryC:\Users\Administrator\.windows-build-tools
  • Installation:vs_BuildTools.exePython - 2.7.15. Amd64. Msi



If there is novs_BuildTools.exe, click here to download:

Link: pan.baidu.com/s/14oAJMdyI… Extraction code: 4grb

Installation node – gyp

cnpm install -g node-gyp



If an error occurs, delete any node-gyp or NPM YARN that has been installed before

Recompile RobotJS

Execute under node_modules\robotjs of the project:

Node-gyp rebuild --python c :\Python27\python.exeCopy the code

Recompile electron

NPM rebuild - runtime = electron - target = 1.1.3 - disturl = https://atom.io/download/atom-shell - abi = 48

–target: electron version –abi: electron abi address for Node: github.com/mapbox/node…



Add the compile command inscriptsIn the

"Rebuild" : "NPM rebuild - runtime = electron - target = 10.1.5 - disturl = https://atom.io/download/atom-shell - abi = 72"

Perform:npm run rebuild

Compiling succeeds if no error is reported:

Reference documentation

Robotjs. IO/docs/electr… Use robotjs. IO /docs/buildi… Robotjs recompile