Robot / robot-js

Native system automation for node.js
http://getrobot.net
zlib License
196 stars 24 forks source link

Couldn't install via npm on win x64 #73

Open Suhail opened 5 years ago

Suhail commented 5 years ago

I ran this:

digit@mighty-dev MINGW64 ~/Desktop/workspace/proj (suhail/events)
$ npm install robot-js

Error:

npm WARN deprecated hawk@3.1.3: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated sntp@1.0.9: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated cryptiles@2.0.5: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated boom@2.10.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@2.16.3: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).

> robot-js@2.0.0 install C:\Users\digit\Desktop\workspace\proj\node_modules\robot-js
> node scripts/install.js || node-gyp rebuild

At line:1 char:25
+ node scripts/install.js || node-gyp rebuild
+                         ~~
The token '||' is not a valid statement separator in this version.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidEndOfLine

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! robot-js@2.0.0 install: `node scripts/install.js || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the robot-js@2.0.0 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!     C:\Users\digit\AppData\Roaming\npm-cache\_logs\2019-06-05T19_55_41_932Z-debug.log

Env

Suhail commented 5 years ago

Update:

When I got rid of the || since powershell doesn't support that and just tried to npm install locally. Effectively, it's now running node-gyp rebuild since there's no pre-built I imagine for Node 12.x.

Building in VS17 went fine & succeeded.

I began to get these errors as well:

[Compiling...]
  NodeRobot.cc 
  NodeImage.cc 
  NodeKeyboard.cc 
  NodeMouse.cc 
  NodeProcess.cc 
  NodeMemory.cc 
  NodeWindow.cc 
  NodeScreen.cc 
c:\users\digit\desktop\workspace\proj\node_modules\robot-js\src\nodeimage.cc(112): error C2661: 'v8::Function::NewInstance': no overloaded function takes 2 arguments [C:\Users\digit\Desktop\workspace\cl 
oudbox\node_modules\robot-js\build\win32-x64-67.vcxproj] 
c:\users\digit\desktop\workspace\proj\node_modules\robot-js\src\nodeimage.cc(204): error C2661: 'v8::Function::NewInstance': no overloaded function takes 2 arguments [C:\Users\digit\Desktop\workspace\cl 
oudbox\node_modules\robot-js\build\win32-x64-67.vcxproj]
c:\users\digit\desktop\workspace\proj\node_modules\robot-js\src\nodeimage.cc(209): error C3536: 's': cannot be used before it is initialized [C:\Users\digit\Desktop\workspace\proj\node_modules\robot 
-js\build\win32-x64-67.vcxproj]
c:\users\digit\desktop\workspace\proj\node_modules\robot-js\src\nodeimage.cc(221): error C2661: 'v8::Function::NewInstance': no overloaded function takes 2 arguments [C:\Users\digit\Desktop\workspace\cl 
oudbox\node_modules\robot-js\build\win32-x64-67.vcxproj]

It seems related to my node version. I want to compile it to use Node 12.x. I noticed the docs are outdated and mentioned some UserMacro -> NodeVersion I could change but I couldn't find that anywhere.

p120ph37 commented 5 years ago

Node 12 has some changes in the ABI, which were breaking builds. I've opened a #74 with some fixes which ought to get node-gyp working again. Alternately, you can run from my prebuilt fork by specifying "robot-js": "github:p120ph37/robot-js#prebuilt" in your package.json.

kkm commented 4 years ago

I use with Node 10, still get the same error.

EDIT: Where should I put fork in package.json?

karliky commented 4 years ago

@kkm Put it inside the dependencies and replace it with the robot-js module. Node 12 is still not supported, we have to merge a PR into master and release the prebuilt binaries. Let's see if @dkrutsko can do it soon 😄

MichaelLeeHobbs commented 4 years ago

This works as of 7/27/2020

// package.json
{
  "name": "robot-js-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "robot-js": "github:p120ph37/robot-js#prebuilt"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

Used yarn install after adding "robot-js": "github:p120ph37/robot-js#prebuilt" to the dependencies.

// index.js
// Node
var robot = require ("robot-js");

// Must be true in order to work
if (robot.Window.isAxEnabled()) {
    var list = robot.Window.getList (".*");

    // List is an array
    list.forEach((w) => {
        console.log(w.getTitle())
        ; // Always contains "title"
    });
}
p120ph37 commented 4 years ago

Yeah, I updated my fork and prebuilt binaries a couple weeks ago. Should work up to Node 14 and Electron 9. I'm waiting for Electron 10 to come out of beta before adding it to the prebuilt list, but so far it looks like it ought to be possible without any additional tweaks to the source.