0

I want to install spookyjs and find it impossible to do so. I've tried three different ways:

  1. Run the standard spookyjs package.json provided in spookyjs github. Then I try to run hello.js and I am greeted with this error.

       C:\Users\User1\Desktop\test2>node hello.js
    events.js:183
          throw er; // Unhandled 'error' event
          ^
    
    Error: spawn casperjs ENOENT
        at _errnoException (util.js:1022:11)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
        at onErrorNT (internal/child_process.js:372:16)
        at _combinedTickCallback (internal/process/next_tick.js:138:11)
        at process._tickCallback (internal/process/next_tick.js:180:9)
        at Function.Module.runMain (module.js:695:11)
        at startup (bootstrap_node.js:188:16)
        at bootstrap_node.js:609:3
    
  2. Installed phantomjs and casperjs globally and package.json installed spooky and tiny-jsonrpc. I get the same error message.

  3. Installed these dependencies from package.json

    "dependencies": {
        "spooky": "^0.2.5",
        "tiny-jsonrpc": "^2.0.1",
        "phantom": "^4.0.12",
        "casperjs": "^1.1.4"
    

I get the same error.

SomeGuyOnAComputer
  • 5,414
  • 6
  • 40
  • 72
user1584421
  • 3,499
  • 11
  • 46
  • 86
  • It's possible the package is dead because the last commit was in May 2016. You might have better luck checking out [puppeteer](https://github.com/GoogleChrome/puppeteer) – SomeGuyOnAComputer Apr 09 '18 at 13:42
  • I found out this: "https://cnpmjs.org/package/phantomjs". I will do further testing. – user1584421 Apr 09 '18 at 14:42
  • I used to use Phantomjs and unfortunately it is also being [deprecated](https://news.ycombinator.com/item?id=16511860) because the top developer is leaving due to chrome's headless browser and `puppeteer`. – SomeGuyOnAComputer Apr 09 '18 at 14:47
  • Therefore i cannot use it? Can puppeteer do what spooky/casper/phantom toolchain offers? – user1584421 Apr 09 '18 at 14:55
  • You can use it but it will eventually be deprecated so it might be better to pivot to a toolchain that will survive. Google's headless api that I mentioned will most likely survive as it has a large company backing. – SomeGuyOnAComputer Apr 09 '18 at 20:01
  • Well, after finding this link https://github.com/SpookyJS/SpookyJS/issues/71. The error stops.But unfortuantely when i run the example, nothing is logged on the screen. – user1584421 Apr 11 '18 at 09:49
  • Can puppeteer simulate a click on a specific div by its classname? – user1584421 Apr 11 '18 at 12:54
  • Yes, it can simulate a click... See [page.click on the api documentation](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageclickselector-options) – SomeGuyOnAComputer Apr 12 '18 at 00:15

1 Answers1

0

I came across this link: Issue

and it detailed the solution. That is this chunk of code:

const
  path = require('path'),
  _ = require('underscore')
;
var
  // close env to pass to spawn
  env = _.clone(process.env),
  // get the PATH - in my local Windows, it was Path
  envPath = env.PATH || env.Path,
  // get path to node_modules folder where casperjs and
  // phantomjs-prebuilt are installed
  // this will be different for you
  binDir = path.join(__dirname, './../../node_modules/.bin'),
  Spooky = require('spooky')
;
// update the path in the cloned env
env.PATH = env.Path = `${envPath};${binDir}`;


var spooky = new Spooky({
  child: {
    // spooky is trying to call casperjs.bat for windows
    // .bat doesn't work, so call the update .cmd file
    // this fixes issue 2 with the file
    command: /^win/.test(process.platform) ? 'casperjs.cmd' : 'casperjs',
    transport: 'http' ,
    spawnOptions: {
      // set the env using cloned version
      // this fixes issue 1 with the path
      env: env
    }
  },
  ... 

So now the program runs without an error. Actually though it runs without anything, because while on the one hand no error pops up, on the other nothing pops up. I debbuged by putting console.log() inside spooky's callback function but nothing is displayed. That is for another question though...

But the error i was receiving has vanished and the interpreter runs the code.

user1584421
  • 3,499
  • 11
  • 46
  • 86