Can't run PhantomJS with mocha on node js


I'm trying to run phantomjs with these params:

mocha-phantomjs -s disk-cache=no --ignore-leaks -R xunit tests/index.html

but allways got this respond:

        throw er; // Unhandled 'error' event
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

I use ubuntu 13, mocha-phantomjs 3.1.0 and node v0.10.15.

Any googling doesn't helps and I just can't figure out what to do. All what i did before, is just install node and mocha-phantomjs

Can anyone help me?

Problem courtesy of: uhthska


I have seen this error on a windows machine, and solved it by copying phantomjs executable to the node.js folder.

Make sure that either phantomjs executable is in PATH or phantomjs executable is in node.js folder.

Solution courtesy of: mm6502


Another option on Windows, that's slightly cleaner:

Download Phantomjs. Decompress the zip someplace (c:\dev\phantom or whatever) and add it to your path.

Install mocha-phantomjs globally using npm:

npm install -g mocha-phantomjs

And you should be all set.

Discussion courtesy of: Eric Brandel

This recipe can be found in it's original form on Stack Over Flow.