robotjs: if u can not rebuild robotjs in electron, it may help you

I find that this module installed by npm i robotjs ,just can’t be rebuilt,I have tried electron-rebuild and node-gyp, none of them works.

but today I cloned this repo and using node-gyp rebuild --runtime=electron --target=6.0.5 --disturl=https://atom.io/download/atom-shell --abi=73, it works. I am so happy although dont know why~~~~~~~~~~

Your Environment

  • RobotJS version: v0.5.1
  • Node.js version: v10.16.3
  • npm version: v6.9.0
  • Operating System: Win10 Pro

About this issue

Most upvoted comments

@12Tall can you elaborate the steps you performed and your electron version?

the electron of my prj is 6.0.7 now.

# d:\prj is my workspace, you can change it to your own 
# for new project: init it firstly, then npm will generate package.json here 
# for existing project: just ignore the following direction 👇
D:\prj> npm init 

# clone this repo in prj 
D:\prj> git clone git@github.com:octalmage/robotjs.git

D:\prj> cd robotjs

D:\prj\robotjs> npm install
# npm install will install electron-1.8.8, 
# I think we can also install the last version

# more info: http://robotjs.io/docs/electron
D:\prj\robotjs> node-gyp rebuild --runtime=electron --target=6.0.7 --disturl=https://atom.io/download/atom-shell --abi=73  

# also you may meet errors abot "nan varibles not defined", execute npm install nan will solve it

# of course, we should replace '\' by '/' in *nix
D:\prj\robotjs> cd ..\

# install local module in nodejs
D:\prj> npm i -D .\robotjs
# then it will add dependencies in package.json
# "devDependencies": {
#   "robotjs": "file:robotjs"
# },

that’s all I have done,and I hope it works well in your prj.

A new version of robotjs supporting the latest NodeJS version will be published soon.

There are a easy way to solved.

If u use yarn yarn add https://github.com/octalmage/robotjs.git\#master, use npm npm install https://github.com/octalmage/robotjs.git\#master

Then run: npm rebuild --runtime=electron --target=6.0.11 --disturl=atom.io/download/atom-shell --abi=73 (I use v6.0.11)

I was also having issues compiling this for newer version of electron, I fixed it by updating the nan module and after that it compiled just fine.