Installing PhantomJS for Yeoman

In order to run Yeoman properly you’ll require a few dependencies like Command Line Tools for Xcode, Homebrew, NodeJS, git, NodeJS, ruby, RubyGems, Compass, jpegtran, optipng, yeoman global npm module and the most important puzzle piece and part of today’s discussion; PhantomJS.

What is PhantomJS?

PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG. It’s mainly used in the test workflow of various open–source projects. It also can be used for headless website testing to run functional tests with frameworks such as Jasmine, QUnit, Mocha, Capybara, WebDriver, and many others.

Why are we talking about PhantomJS today?

The reason I mention PhantomJS today is because I came across some difficulties on my Mac when running curl -L | bash (this command runs an audit script to determine which dependencies are or are not installed for Yeoman to function properly). Unfortunately, the output of this command returned the following in my case: PhantomJS not installed. Good news though, here’s the run down I went through which will guide you towards a solution –at least what I found to work for me.

NOTE: The following directions assume you have Homebrew installed. I will not be discussing Homebrew and the installation process.

First Update Homebrew

When I was updating brew I was using the following command…

brew update

The problem I ran into was the following error output…

Failed while executing git pull master
The following untracked working tree files would be overwritten by merge:
Please move or remove them before you can merge.

After much scanning and IRC chatting I found the fix on this Github Issue Tracker thread.

Now Install PhantomJS

Ok, so now that the problem with brew update was out of the way I needed to install phantom…

brew install phantomjs

Of course I got yelled at in the output with the following message…

Error: phantomjs-1.7.0 already installed, it's just not linked

Just Link Phantom Right?

Well it did sound simple but…

brew link phantomjs

Gave me this…

Error: Linking /usr/local/Cellar/phantomjs/1.7.0...
Warning: Could not link phantomjs. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/phantomjs/1.7.0/bin/phantomjs /usr/local/bin/phantomjs may already exist. /usr/local/bin may not be writable.

I bet you’re thinking about running sudo brew link phantomjs right about now –right?

Shit! Fuck! Shit!

Calm down we still got you covered. So sudo didn’t work out after all. Instead of running sudo, It’s recommended to chown your usr/local dir.
To do so, run the following command in your Terminal…

sudo chown -R $USER /usr/local

Just remember to replace $USER with your username, but If you did it without changing the $USER part it’s the same if $USER will normally be the same as your current name.

Boo Boo all Better

The crummy part is out of the way now because all you have to do is run brew link phantomjs one final time and you’re all good! PhantomJS should be installed at last. Happy Yeoman-ning. Questions? Ask.

Yeoman IRC

Channel: #yeoman


Web Development & Design, Technical Writing, Interaction Design, Open Source Maker & Contributor. Helping Create A Better Web.
  1. Nice! Love your exasperations!

    1. Thanks Dave. I definitely keep it very G rated for sure.

Leave a Reply

Your email address will not be published. Required fields are marked *

show formatting examples
<pre class="language-[markup | sass | css | php | javascript | ruby | clike | bash]"><code>
…code example goes here…

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment Preview

  1. John Doe shouted this comment preview: