Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PhantomJS on Mac

I'm trying to install PhantomJS on my Mac (Yosemite).

I did the following:

npm install phantomjs 

Then I did:

npm install phantomjs-prebuilt 

Both of which appear in my node_modules. But when I try to run phantomjs --versionI get

   -bash: phantomjs: command not found 

Also tried installing the binary from the downloads website, but nothing. What am I missing? End goal is to use casperjs but currently casper is asking

Fatal: [Errno 2] No such file or directory; did you install phantomjs? 

I thought I did....?

like image 762
jblakeley Avatar asked May 03 '16 00:05

jblakeley


People also ask

How do I run PhantomJS?

Go to the “bin” folder and check phantomjs.exe file. If you are using it on a Windows OS, then you can set the path variable under the environment variable for fast access through command prompt. The command to run the PhantomJS program: C:\> phantomjs [options] file.


2 Answers

If you are using Homebrew, you can type:

brew tap homebrew/cask brew cask install phantomjs 
like image 137
Vladtn Avatar answered Sep 21 '22 02:09

Vladtn


  1. Download phantomjs latest version (ex: phantomjs-2.1.1-macosx.zip) from http://phantomjs.org/download.html
  2. Extract it to some path(ex: ~/Desktop/phantomjs-2.1.1-macosx)
  3. Run this command on terminal - sudo ln -n ~/Desktop/phantomjs-2.1.1-macosx/bin/phantomjs /usr/local/bin/
  4. Launch phantomjs from the terminal by command: phantomjs
  5. Check phantomjs version by command: phantomjs -v
  6. Check the phantomjs path by command: which phantomjs
like image 43
user2625094 Avatar answered Sep 20 '22 02:09

user2625094