RobotJS를 실험실에 설치하는 중 오류 발생
8824 단어 Node.jsRaspberryPiJavaScript
https://github.com/octalmage/robotjs
자동 마우스 탐색
샘플이지만 이런 코드로 마우스를 제어할 수 있다.
app.js
'use strict';
// Move the mouse across the screen as a sine wave.
const robot = require("robotjs");
// Speed up the mouse.
robot.setMouseDelay(2);
const twoPI = Math.PI * 2.0;
const screenSize = robot.getScreenSize();
const height = (screenSize.height / 2) - 10;
const width = screenSize.width;
for (let x = 0; x < width; x++){
const y = height * Math.sin((twoPI * x) / width) + height;
robot.moveMouse(x, y);
}
Raspberry Pi에 설치하는 중 오류 발생
$ npm i --save robotjs
> [email protected] install /home/pi/n0bisuke/splatoon_audio/robottest/node_modules/robotjs
> prebuild-install || node-gyp rebuild
prebuild-install info begin Prebuild-install version 2.4.1
prebuild-install info looking for local prebuild @ prebuilds/robotjs-v0.4.7-node-v59-linux-arm.tar.gz
prebuild-install info looking for cached prebuild @ /home/pi/.npm/_prebuilds/https-github.com-octalmage-robotjs-releases-download-v0.4.7-robotjs-v0.4.7-node-v59-linux-arm.tar.gz
prebuild-install http request GET https://github.com/octalmage/robotjs/releases/download/v0.4.7/robotjs-v0.4.7-node-v59-linux-arm.tar.gz
prebuild-install http 404 https://github.com/octalmage/robotjs/releases/download/v0.4.7/robotjs-v0.4.7-node-v59-linux-arm.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=9.2.0 runtime=node arch=arm platform=linux)
make: Entering directory '/home/pi/n0bisuke/splatoon_audio/robottest/node_modules/robotjs/build'
CXX(target) Release/obj.target/robotjs/src/robotjs.o
cc1plus: warning: command line option '-Wbad-function-cast' is valid for C/ObjC but not for C++
In file included from ../src/keypress.h:6:0,
from ../src/robotjs.cc:7:
../src/keycode.h:103:23: fatal error: X11/Xutil.h: No such file or directory
#include <X11/Xutil.h>
^
compilation terminated.
robotjs.target.mk:112: recipe for target 'Release/obj.target/robotjs/src/robotjs.o' failed
make: *** [Release/obj.target/robotjs/src/robotjs.o] Error 1
make: Leaving directory '/home/pi/n0bisuke/splatoon_audio/robottest/node_modules/robotjs/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/pi/.nodebrew/node/v9.2.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:159:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 4.4.21-v7+
gyp ERR! command "/home/pi/.nodebrew/node/v9.2.0/bin/node" "/home/pi/.nodebrew/node/v9.2.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/n0bisuke/splatoon_audio/robottest/node_modules/robotjs
gyp ERR! node -v v9.2.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2017-12-13T08_00_26_277Z-debug.log
한 X11/Xutil.h: No such file or directory
곳이 이상해요.X11/Xutil.h: No such file or directory
https://stackoverflow.com/questions/5299989/x11-xlib-h-not-found-in-ubuntu
여기
$ sudo apt-get install libx11-dev
될 것 같다다시 실행 후 오류 발생
../src/mouse.c:12:35: fatal error: X11/extensions/XTest.h: No such file or directory
#include <X11/extensions/XTest.h>
X11/extensions/XTest.h: No such file or directory
https://stackoverflow.com/questions/5073040/how-to-find-x11-extensions-xtest-h
여기를 참고하여 순서대로 아래의 조작을 집행하다
$ sudo apt-get install apt-file
$ sudo apt-file update
$ apt-file search "X11/extensions/XTest.h"
$ sudo apt-get install libxtst-dev
이렇게 다시 설치하면 순조롭다.
Reference
이 문제에 관하여(RobotJS를 실험실에 설치하는 중 오류 발생), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/n0bisuke/items/2075ab1c72e59ac74e12텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)