casperjs does not find phantomjs

Faced the same problem when installed casper with npm globally on osx. At first I've set environment variable PHANTOMJS_EXECUTABLE to path where phantomjs was installed (it's usually /usr/local/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs phantomjs) with

export PHANTOMJS_EXECUTABLE=/usr/local/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs phantomjs

this helped only partially as I still got an error like there's no file nor folder /usr/local/bin/phantomjs, so I've just created symlink and pointed it to real binary folder with

ln -s /usr/local/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs /usr/local/bin/phantomjs

hope this will help someone :)


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