casperjs does not find phantomjs

toom picture toom · Oct 20, 2013 · Viewed 21.4k times · Source

I've downloaded the latest version of casperjs (1.03) and phantomjs (1.9.2).

So I took this little simple script from the casper page:

var casper = require('casper').create({
    verbose: true,
    logLevel: "debug"
});
var casper = new require('casper').Casper();

and when I try to run it I get the following error:

noname:phantomjs-1.9.2 Tom$ casperjs/bin/casperjs tipico2.js 
Fatal: [Errno 2] No such file or directory; did you install phantomjs?

So, this is my directory structure:

phantomjs-1.9.2/ <-- the folder containing phantomjs
phantomjs-1.9.2/casperjs/ <-- a subfolder containting casperjs

Why does it not work?

Answer

toom picture toom · Oct 20, 2013

The solution is actually very simple. Just export the path where the binary of phantomjs is. In my case this is /Users/Tom/Downloads/phantomjs-1.9.2/bin, hence

export PATH=$PATH:/Users/Tom/Downloads/phantomjs-1.9.2/bin