Closed drorma closed 11 years ago
Never mind.
process.env.PATH = process.env.PATH + ":" + __dirname +
'/tools/phantomjs/bin:' + __dirname + '/tools/casperjs/bin';
Before the grunt config seems to do the trick.
Did you put the above code in your Gruntfile.js ?
Yeah:
process.env.PATH = process.env.PATH + ':' + __dirname +
'/tools/phantomjs/bin:' + __dirname + '/tools/casperjs/bin';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
...
Phantom already supports Environment Variables.
You can override PhantomJS like so: process.env["PHANTOMJS_EXECUTABLE"] = /path/to/binary
As of v0.3.3 - Casper is now managed through a local dependency (npm install)
I can also expose another environment variable for casper but am curious as to why you need this?
I'm trying to create a test case project for this but haven't had time yet.
This issue arose when I had at one point installed phantomjs via homebrew, thus the original path was /usr/local/bin/phantomjs. I removed that install, because I wanted npm to manage casperjs and phantomjs. So then I did npm install -g phantomjs casperjs
.
Somehow my project and the grunt-casper npm package was still looking for phantomjs in /usr/local/bin/phantomjs
, but it wasn't there anymore.
I made a temporary work-around by making a symbolic link ln -s /usr/local/opt/nvm/v0.10.26/bin/phantomjs /usr/local/bin/phantomjs
but I'd love to dig in to why it's not working with setting the environment variable, or @drorma 's code above.
I just uninstalled phantomjs
npm install phantomjs -g
which phantomjs
- /usr/local/bin/phantomjs
So it installs correctly for me from scratch.
It may have something to do with NVM and the pathing around that.
Yes, thanks. I'd love to figure out how to make this work with NVM, because without NVM my npm is frequently out of date. I brew install nvm instead of brew install node now. Because, I want npm to manage my node packages instead of homebrew. Package managers managing package managers... :warning:
It looks like I should write a check around line 49 of grunt-casper/tasks/lib/casper.js to see if phantomjs.path is pointing at a file that is actually executable, and at least raise an error if it's not. https://github.com/iamchrismiller/grunt-casper/blob/master/tasks/lib/casper.js#L49
Do you think this is the right approach?
Be nice to be able to specify the paths to casper and phantom as options in the grunt file, rather than having to add them to the environment variable