How to use local phantomjs (karma-phantomjs-launcher)?

3,267 views
Skip to first unread message

Yang Zhang

unread,
May 14, 2013, 7:10:10 PM5/14/13
to karma...@googlegroups.com
I'd like to allow users to simply run `npm install; grunt test` on my
project (which includes phantomjs in devDependencies) and thus use the
local phantomjs instead of having to install it globally/muck with
their PATH. How can I do this?

When I just do this now, I get:

ERROR [launcher]: Cannot start PhantomJS
execvp(): No such file or directory

I found https://github.com/karma-runner/karma-phantomjs-launcher but
I'm not sure how to leverage it. I installed it, but how do I get
karma to start using this instead of its own PhantomJS.js file? It
resembles karma's built-in PhantomJS.js file except for what appear to
be the key lines:

24,26c22,24
< linux: 'phantomjs',
< darwin: '/usr/local/bin/phantomjs',
< win32: process.env.ProgramFiles + '\\PhantomJS\\phantomjs.exe'
---
> linux: require('phantomjs').path,
> darwin: require('phantomjs').path,
> win32: require('phantomjs').path

Thanks.

Vojta Jína

unread,
May 20, 2013, 9:00:29 PM5/20/13
to karma...@googlegroups.com
The karma-phantomjs-launcher does include a local version of phantomjs. This plugin can be used with karma 0.9+ which is only released in canary channel.
You can try it with "npm install karma@canary".

V.



--
You received this message because you are subscribed to the Google Groups "karma-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to karma-users...@googlegroups.com.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Rob Barreca

unread,
May 31, 2013, 7:31:53 PM5/31/13
to karma...@googlegroups.com
I'm having similar issue, although I have a workaround. I'm wondering if there are docs on the proper install of karma-phantomjs-launcher? I've done

npm install -g karma@canary

then all incarnations of `npm install -g karma-phantomjs-launcher`, without -g in my project root, in /usr/local/share/npm/lib/node_modules/karma folder but I always get

ERROR [launcher]: Cannot start PhantomJS 
        execvp(): No such file or directory 

If I add `console.log(require('phantomjs').path);` to index.js I see `/usr/local/share/npm/lib/node_modules/karma/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs` which doesn't exist.

Of course it works if I set a PHANTOMJS_BIN env variable to point to phantomjs I downloaded from brew. 

But, I'm trying to ensure I know the _right way_ to install this and other karma plugins so I can show 10 people on our team how to install on their boxes.

-R

Vojta Jína

unread,
Jun 6, 2013, 6:41:09 PM6/6/13
to karma...@googlegroups.com
Hi Rob,

karma behaves similarly to grunt-cli (when you execute "karma" command, if there is a local version of karma, it will use that version), so you can have a specific karma version per project.

The idea with karma + plugins is to specify it as a dependency in your project/package.json, eg.
{
  devDependencies: {
    "karma": "~0.9" // canary
    // plugins that this particular project requires
    "karma-safari-launcher": "*"
}

So that every developer on the project can just do "npm install".

V.


--

Vojta Jína

unread,
Jun 7, 2013, 12:12:08 PM6/7/13
to karma...@googlegroups.com
Thanks Rob, I will look into the PR...


On Fri, Jun 7, 2013 at 2:03 AM, <rob.b...@inmobi.com> wrote:
Regarding the PhantomJS issue, I opened a PR at https://github.com/karma-runner/karma-phantomjs-launcher/pull/4 that fixed it for me. 

Thanks for the other info on installing Vojta!

-R

On Tuesday, May 14, 2013 1:10:10 PM UTC-10, Yang Zhang wrote:

_____________________________________________________________
The information contained in this communication is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it. It may contain confidential or legally privileged information. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by responding to this email and then delete it from your system. The firm is neither liable for the proper and complete transmission of the information contained in this communication nor for any delay in its receipt.
Reply all
Reply to author
Forward
0 new messages