I am trying to create a NodeJS program that utilizes CasperJS within it. I have run into the error that the module 'casper' cannot be found. As a result, I have tried to npm install spooky --save as I have read around that it is a driver, but I am still getting the same error as I was getting before.
Also, before trying to install SpookyJS, I tried
var phantom = require('phantom');
phantom.casperPath = '/path/to/casperjs';
phantom.injectJs(phantom.casperPath + '/bin/bootstrap.js');
Which then gave me the error that injectJs is not a function. Any and all help appreciated.
First of all, to contextualize a bit, here is an important reminder for everyone:
This is where SpookyJS comes into play... But how to make it work? (I assume you are on Linux.)
1. Make sure you have the right environment
Note: SpookyJS works on my computer (Arch Linux) and I have the following setup:
node --version
---> v7.7.4npm --version
---> 4.4.4phantomjs --version
---> 2.1.1casperjs --version
---> 1.1.3PhantomJS and CasperJS are installed globally.
2. Install SpookyJS locally (and its dependency:
tiny-jsonrpc
)Create an empty directory and run
npm i spooky tiny-jsonrpc
inside. We do not need apackage.json
here, so you can forget about--save
or--save-dev
.3. Test the given example
If SpookyJS is installed, you should have a local
node_modules
directory. Now, try to run the following command:If you get "Hello, from Spooky the Tuff Little Ghost - Wikipedia", congrats! You can now integrate SpookyJS in your project, but you will have to respect the syntax presented in
hello.js
...