javascriptnode.jscasperjsspookyjs

Can´t load casperjs module placed at the same parent node_modules directory as spookyjs


I only have spookyjs installed in the node_modules folder of my project, but I am only able to successfully execute my scripts (or the example one included) when casperjs is installed with the global (-g) flag, not when I have it in the same nodes_modules as spookyjs.

Is there any configuration or step that I may be overlooking here? Thank you!


Solution

  • CasperJS is not a node module that you can require. It is installed globally (-g) so that spooky can find the executable in the PATH. You don't need npm to install CasperJS. Just put it somewhere and add its directory to the PATH.

    As said in the comments, it is also possible to put a path to the CasperJS executable/shell script as an option during creation:

    var spooky = new Spooky({
        child: {
            command: 'path/to/executable'
        }
    }, function(err){
        ...
    });