Reputation: 4886
My package.json looks like this..
"karma-phantomjs-launcher": "^0.1.4",
"karma-safari-launcher": "^0.1.1",
"karma-sinon-chai": "~0.2.0",
"karma-spec-reporter": "~0.0.16",
"mocha": "~1.20.1"
my npm version is 2.2.0
whay am I getting this when I run karma test - karma start my.conf.js
Upvotes: 26
Views: 24793
Reputation: 4886
This seems to be an issue with phantom js runner and phantom js versions.
https://github.com/karma-runner/karma-phantomjs-launcher/issues/31
How I fixed my issue..
# install
npm install -g karma-phantomjs-launcher
# temporary path.. set the path
export PHANTOMJS_BIN=/usr/local/lib/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs
karma start my.conf.js
Upvotes: 19
Reputation: 21
I solved this problem on OSX: Remove and create file karma.config.js
using sudo.
Upvotes: 2
Reputation: 5254
Run the below commands:
npm remove phantomjs -g
npm remove phantomjs
npm install phantomjs
Once you do this installation:
you will get a message like the below one:
Linking to global install at /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
Copy this path and run:
export PHANTOMJS_BIN=/usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
Basically what is happening is: karma is trying to launch the browser but unable to find its bin. Once you export the path to the correct path, it runs.
Upvotes: 1
Reputation: 382
Ran into a problem like this one. What I did was install the phantomjs globally npm install -g phantomjs
. Then went to the karma-phantomjs-launcher
module folder and opened index.js
file. Then I went to the phantomJSExePath
function and commented out the prior contents(not sure if it is safe to do what I did). Then I placed
return 'C://Users/user/AppData/Roaming/npm/node_modules/phantomjs/lib/phantom/phantomjs.exe';
Saved me from retyping the temporary export.
Upvotes: 1
Reputation: 171
I ran into this same problem. The fix is to manually set the PHANTOMJS_BIN
variable to point to the correct phantomjs path. Somehow karma launcher tries to look at the wrong path set by PHANTOMJS_BIN
.
Here is what worked for me:
$ echo $PHANTOMJS_BIN
/usr/local/lib/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs
$ export PHANTOMJS_BIN=/usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs
$ grunt test
everything is ok after that.
Upvotes: 12
Reputation: 5893
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']);
Upvotes: 2
Reputation: 41
I remove all my node_modules folder under my Project and run "npm install". This did fix my problem.
Upvotes: 4
Reputation: 2976
My karma.conf.js
had this line: process.env.PHANTOMJS_BIN = 'node_modules/karma-phantomjs-launcher/node_modules/.bin/phantomjs';
at the top. I just realized that! I commented it, and it works
Upvotes: 2
Reputation: 41
I hit this problem with [email protected], where I had also installed [email protected].
Turns out that phantomjs is deprecated, replaced with phantomjs-prebuilt.
Uninstalling both packages and reinstalling phantomjs-prebuilt fixed the problem with karma-phantomjs-launcher:
npm -g remove phantomjs phantomjs-prebuilt
npm -g install phantomjs-prebuilt
Upvotes: 4
Reputation: 3456
had same problem, did all above, no result just deleted 'karma-phantomjs-launcher' folder from global node_modules and project local, called 'npm install' and all is fine!
Upvotes: 1
Reputation: 1598
I was having this issue with an older version of node, too. If you don't want to have to hard-code this environment variable, updating your version of node will solve the problem. Just do the following (OSX instructions):
npm uninstall -g phantomjs
npm cache clean -f
brew upgrade nodejs
rm -rf node_modules
npm install -g YOUR_GLOBAL_DEPENDENCIES
npm install
Edit: updated instructions to make sure there is no global phantomjs dependency
Upvotes: 16