Installing CasperJS on Windows: How to do it correctly?

前端 未结 8 1312
天命终不由人
天命终不由人 2020-12-28 13:52

I know there is a documentation from CasperJS website about how to install CasperJS on Windows, but bear with me these guys only explained for the pros only.

If you

相关标签:
8条回答
  • 2020-12-28 14:51

    Poor documentation for windows. http://casperjs.org/installation.html#windows

    It starts off assuming you have already installed without telling you how to install.

    So here it is if anyone else is confused about this. There is no actual install. It's just extracting zip contents to the right place.

    1. download phantomjs for windows from the phantomjs site (it's a zip with binary inside)
    2. extract the contents to C:\phantomjs
    3. download the casperjs zip file from the casperjs website
    4. extract the contents to C:\casperjs
    5. Now you can add the following to the end your system or user PATH variable

      ;C:\phantomjs;C:\casperjs\batchbin

    6. restart cmd.exe to pick up the new path variable or logout/login if you are running Console2 or Conemu terminal emulator (they won't pick up new paths by a simple close and re-open)

    Now in the docs it says to run it like this

    casperjs.bat myscript.js
    

    Actually since both phantomjs.exe and casperjs.bat are now in the system PATH you can leave off the extension like this.

    casperjs myscript.js
    

    And when running phantomjs.exe just run

    phantomjs
    

    One more thing. It really doesn't matter where you install as long as you add that path to the system PATH. I installed to C:\usr\phantomjs and C:\usr\casperjs.

    0 讨论(0)
  • 2020-12-28 14:51

    Many of the other answers are out of date. Since it seems like the correct install process keeps changing all the time, I suspect my answer will be out of date also in a few days, but as of March 19, 2015, this is the answer. The other answers, even highly upvoted ones, do not work, so don't waste your time. Good luck. Casperjs seems quite good.

    If you download PhantomJS 2.0 and casperjs 1.1-beta3 zip file and put the batchbin directory in the path and put phantom exe in that same folder, then run casperjs, on Windows 8.1 I get the error "CasperJS needs PhantomJS v1.x".

    So, I got the latest casperjs direct from github, which has no batchbin directory, so I put just the C:\casperjs\bin directory in the path instead and this worked (sort of, I mean it seems to work well enough for me - although running casperjs c:\casperjs\tests\selftest.js seems to have a number of failing tests).

    So to recap, the bad news is only the very latest bleeding edge casperjs works. The good news is the install is 1,2,3 simple:

    1. Clone latest casperjs from github into c:\casperjs.
    2. Copy phantomjs.exe (ver 2.0) to c:\casperjs\bin
    3. Add c:\casperjs\bin to your windows path
    0 讨论(0)
提交回复
热议问题