7

this might sound like a stupid issue but I can't seem to figure out at all why

I downloaded the windows binary and following the quickstart instructions and tried using the examples, but whatever and whenever I type anything in the console I always get "parse error"

I tried:

phantom hello.js

phantomjs hello.js

and some of the example scripts, and I always get 'parse error'

the hello.js file simply has this

console.log('Hello, world!');

phantom.exit();

I have no clue what's wrong... any help would be appreciated...I'm sure this will turn out to be something stupid so I appreciate your time! thanks

roy naufal
  • 379
  • 1
  • 8
  • 19
  • See if `phantomjs --version` works at all. – Ariya Hidayat May 05 '12 at 04:03
  • no, also gives me parse error... phantom.exit() does work though – roy naufal May 05 '12 at 07:24
  • 1
    Then something is seriously wrong with your setup. `--version` should always just display the version information. – Ariya Hidayat May 05 '12 at 22:47
  • yes, exactly...thing is i just downloaded the binary as it is from the site, didnt compile it or anything...thought maybe i have to do somthing or i missed something .. ill try downloading again – roy naufal May 06 '12 at 08:13
  • still same problem...I tried this: phantomjs> phantom --version Parse error phantomjs> phantomjs --version Parse error I'm using Windows 7 Ultimate 64 bit... I downloaded phantomjs-1.5.0-win32-static.zip, maybe it doesn't work on 64 bit? – roy naufal May 06 '12 at 08:17
  • 4
    There is your problem, the prompt from PhantomJS is for typing JavaScript code, not some 'phantom foobar'. When I wrote `phantomjs --version`, it is meant to be typed on the **Windows command prompt**, and not PhantomJS own REPL. Please read the documentation wiki for more details. – Ariya Hidayat May 06 '12 at 11:41
  • ah ok thanks, oddly enough I did not think of that..I think you should mention to run that from command prompt, the fact you can phantomjs itself might be misleading – roy naufal May 07 '12 at 08:21
  • It's already in the docs: "If PhantomJS is invoked without any argument, it will enter the interactive mode (REPL)." – Ariya Hidayat May 07 '12 at 12:39

2 Answers2

8

Add 'phantomjs-1.5.0-win32-static' folder path to your system environment variable path and try phantomjs --version in new cmd prompt. If you can able to get the version correctly then you can execute your .js as below

phantomjs hello.js
premnathcs
  • 545
  • 3
  • 11
3

Your shoudnt run the phantomjs.exe file directly. you have to run it from CMD!

T.Todua
  • 53,146
  • 19
  • 236
  • 237