I met the same issue sometimes. I have a gruntfile.js
and I had package.json
where I explicitly add phantomjs-prebuilt
as dependency. But my CI Server sometimes can run grunt karma
smoothly while sometimes fails claiming No binary for PhantomJS browser on your platform. Please, set “PHANTOMJS_BIN” env variable
.
So I add a grunt task
to ensure the PHANTOMJS_BIN
variable was set before the test runs, and then solved the annoying issue.
grunt.registerTask('ensurePhantomJsPath', function () {
process.env.PHANTOMJS_BIN = './node_modules/phantomjs-prebuilt/bin/phantomjs';
console.log(process.env.PHANTOMJS_BIN);
});
So finally the Gruntfile.js
looks like this:
grunt.registerTask('ensurePhantomJsPath', function () {
process.env.PHANTOMJS_BIN = './node_modules/phantomjs-prebuilt/bin/phantomjs';
console.log(process.env.PHANTOMJS_BIN);
});
grunt.registerTask('test', ['ensurePhantomJsPath', 'karma']);