6

Environment: Windows 7, Phantomjs version 1.8.0.

I try to run any .js file from 'examples' folder, installed Phantom.js before, added path to the PATH variable, checked version like

phantomjs --version

and it works.

But when I try to run

phantomjs examples/version.js

then get 'Can't open version.js'

I've checked file security settings and run cmd like administrator, but still the same result.

I'll appreciate any help to solve this issue. Thanks in advance.

5
  • 1
    Does it work when you pass an absolute path to phantomjs? Does it find the file when you type ls examples/version.js? Commented Dec 26, 2012 at 13:45
  • Yes, it works with absolute file path. Thanks Blaise. But could you please explain the reason? And how to get it work with relative path? Commented Dec 26, 2012 at 13:52
  • 2
    If you want to use a relative path, you should first cd to the dir that contains the examples dir. The path is relative to the current path in Command, not to the phantomjs dir. Commented Dec 26, 2012 at 14:02
  • Thanks again. Actually I try to run qunit tests like it's shown here: github.com/jquery/qunit/blob/master/addons/phantomjs/README.md Commented Dec 26, 2012 at 14:14
  • Here follows example from README.md in your link: phantomjs runner.js localhost/qunit/test/index.html. As you can see, runner.js is executed from current directory. Please, be more careful next time. Commented Dec 28, 2012 at 11:41

3 Answers 3

7

Was having the same trouble. Finally solved it by specifying absolute path to phatnomjs executable.

instead of:

phantomjs myjsfile.js

do:

/my/absolute/path/to/phantomjs/phantomjs myjsfile.js

I suspect setting up PATH to it will have the same effect, have not tested it though.

Sign up to request clarification or add additional context in comments.

Comments

1

In my case,

/mypath/phantomjs /mypath/myfile.js

It takes three days for finding this out. Pretty wired syntax to me.

If it doesn't work then use . in front of first /

    ./mypath/phantomjs ./mypath/myfile.js

. means base dir as you set in the R studio

Comments

0

In my case I was just not in the right folder, make sure of being in the exact same folder as "myfile.js"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.