Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: PhantomJS not found

I have installed nodejs 0.10.15 on debian 6. Using npm I have then installed:

sudo npm install grunt-cli -g

I have also executed npm install in my local test directory (downloading the necessary dependencies to the node_modules directory) which contains the following package.json file:

{
  "name": "sample-name",
  "version": "1.4.0",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-qunit": ">0.0.0",
    "grunt-qunit-istanbul": ">0.0.0"
  }
}

here is the output when installing phantomjs:

...
Writing location.js file
Done. Phantomjs binary available at /home/myuser/Test/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs
Done. Phantomjs binary available at /home/myuser/Test/node_modules/grunt-qunit-istanbul/node_modules/grunt-lib-phantomjs-istanbul/node_modules/phantomjs/lib/phantom/bin/phantomjs
[email protected] node_modules/grunt
├── [email protected]
...

But when I run grunt test from the test dir I get:

Running PhantomJS...ERROR
>> In order for this task to work properly, PhantomJS must be installed locally
>> via NPM. If you're seeing this message, generally that means the NPM install
>> has failed. Please submit an issue providing as much detail as possible at:
>> https://github.com/gruntjs/grunt-lib-phantomjs/issues
Warning: PhantomJS not found. Use --force to continue.

If I run the phantomjs script installed in the previous specified location nothing happens, I get exit code 127 though (indicating problem PATH :http://tldp.org/LDP/abs/html/exitcodes.html). If I cat the phantomjs bash script it looks like this:

#!/usr/bin/env node

var path = require('path')
var spawn = require('child_process').spawn

var binPath = require(path.join(__dirname, '..', 'lib', 'phantomjs')).path

var args = process.argv.slice(2)

// For Node 0.6 compatibility, pipe the streams manually, instead of using
// `{ stdio: 'inherit' }`.
var cp = spawn(binPath, args)
cp.stdout.pipe(process.stdout)
cp.stderr.pipe(process.stderr)
cp.on('exit', process.exit)

process.on('SIGTERM', function() {
  cp.kill('SIGTERM')
  process.exit(1)
})

As I understand this means that phantomjs is executed inside node. If I start node enter the path var I get:

:~$ env node
> var path = require('path')
undefined
> 

(which I understand is default behavior: node.js displays "undefined" on the console)

Any suggestions to further debug this problem?

like image 896
so12345 Avatar asked Aug 13 '13 19:08

so12345


People also ask

How install PhantomJS on Windows?

For WindowsDownload the zip file, unpack it and you will get an executable phantom.exe. Set the PATH environment variable to the path of phantom.exe file. Open a new command prompt and type phantomjs –v. It should give you the current version of PhantomJS that is running.


1 Answers

Try running

npm uninstall phantomjs

then running

npm install phantomjs -g

This should make sure phantom's installed with the command line, so that grunt can use it, and also should make sure that it installed cleanly.

like image 132
Brandon Anzaldi Avatar answered Oct 21 '22 09:10

Brandon Anzaldi