Installing CasperJS on Windows: How to do it correctly?

前端 未结 8 1329
天命终不由人
天命终不由人 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.

提交回复
热议问题