octalmage / robotjs

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

I cannot install robotjs #754

Open gokul-3 opened 9 months ago

gokul-3 commented 9 months ago

When I try to install robotjs, it ends with error

npm ERR! code 1 npm ERR! path /home/gokulakannan/robot/node_modules/robotjs npm ERR! command failed npm ERR! command sh -c prebuild-install || node-gyp rebuild npm ERR! make: Entering directory '/home/gokulakannan/robot/node_modules/robotjs/build' npm ERR! CXX(target) Release/obj.target/robotjs/src/robotjs.o npm ERR! make: Leaving directory '/home/gokulakannan/robot/node_modules/robotjs/build' npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@10.0.1 npm ERR! gyp info using node@20.7.0 | linux | x64 npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3" npm ERR! gyp info spawn /usr/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/home/gokulakannan/robot/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/gokulakannan/robot/node_modules/robotjs/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/gokulakannan/robot/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/gokulakannan/.cache/node-gyp/20.7.0/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/home/gokulakannan/.cache/node-gyp/20.7.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/gokulakannan/robot/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/home/gokulakannan/.cache/node-gyp/20.7.0/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/gokulakannan/robot/node_modules/robotjs', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! cc1plus: warning: command-line option ‘-Wbad-function-cast’ is valid for C/ObjC but not for C++ npm ERR! In file included from ../src/keypress.h:6, npm ERR! from ../src/robotjs.cc:7: npm ERR! ../src/keycode.h:112:10: fatal error: X11/Xutil.h: No such file or directory npm ERR! 112 | #include <X11/Xutil.h> npm ERR! | ^~~~~ npm ERR! compilation terminated. npm ERR! make: *** [robotjs.target.mk:135: Release/obj.target/robotjs/src/robotjs.o] Error 1 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: make failed with exit code: 2 npm ERR! gyp ERR! stack at ChildProcess. (/home/gokulakannan/robot/node_modules/node-gyp/lib/build.js:209:23) npm ERR! gyp ERR! System Linux 6.1.0-1029-oem npm ERR! gyp ERR! command "/usr/local/lib/node_modules/node/bin/node" "/home/gokulakannan/robot/node_modules/.bin/node-gyp" "rebuild" npm ERR! gyp ERR! cwd /home/gokulakannan/robot/node_modules/robotjs npm ERR! gyp ERR! node -v v20.7.0 npm ERR! gyp ERR! node-gyp -v v10.0.1 npm ERR! gyp ERR! not ok

what #include <X11/Xutil.h> means? Is there any dependency for this package

orange250 commented 9 months ago

window OS?need build 需要编译 node-gyp 工具

  1. 安装 python3.11 2.安装visual studio 2022 支持桌面C++的选项√上
  2. cd到 robot目录 node-gyp rebuild . 多看看 http://robotjs.io/docs/building
estoylive commented 9 months ago

wtf dude? speak English please

s1hofmann commented 9 months ago

@gokul-3 what #include <X11/Xutil.h> means? Is there any dependency for this package that's a C header for X11, which is required to build robotjs on your Linux machine. You'll have to install it using whichever package management your distribution uses.

As an alternative, nut.js is fully prebuilt for macOS, Windows and Linux and provides an actively maintained alternative to robotjs

DanielMcAssey commented 8 months ago

We also maintain a working fork of RobotJS, which is actively maintained as we use it in several of our projects. https://github.com/hurdlegroup/robotjs

It includes many of the fixes and uses NAPI, and includes prebuilt binaries for all available platforms

orange250 commented 8 months ago

作业已收到,请利用假期充实自己,你的时间由你自己掌控

ftyszyx commented 2 months ago

Robotjs (https://github.com/octalmage/robotjs)is build use V8 API.So it must be rebuilt for different Node versions. This is a big trouble when installing on a platform that has no build environment.. So I rewrapped Robotjs with Node API and prebuilt it. Now you can install robotjs_addon with just one command npm install robotjs_addon And it is compatible with different Node versions. It's open source. You can check it out if you are interested.https://github.com/ftyszyx/robotjs Warm: some api is removed,because there is no need for me, you can help to improve.

orange250 commented 2 months ago

作业已收到,请利用假期充实自己,你的时间由你自己掌控