First of all, to contextualize a bit, here is an important reminder for everyone:
While CasperJS is installable via npm, it is not a NodeJS module and will not work with NodeJS out of the box. You cannot load casper by using require(‘casperjs’) in node. Note that CasperJS is not capable of using a vast majority of NodeJS modules out there. Experiment and use your best judgement.
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
- Node.js >= 0.8
- PhantomJS >= 1.9
- CasperJS >= 1.0
Note: SpookyJS works on my computer (Arch Linux) and I have the following setup:
node --version
---> v7.7.4
npm --version
---> 4.4.4
phantomjs --version
---> 2.1.1
casperjs --version
---> 1.1.3
PhantomJS 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 a package.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:
node node_modules/spooky/examples/hello.js
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
...