Simple installation of NodeJS, PhantomJS, and CasperJS

CasperJS version

I have mentioned using CasperJS for screenshots previously, the awesome navigation scripting and testing utility for PhantomJS (headless webkit browser for NodeJS), but I wanted to cover something that can be a bit painful at times: installation. You can install all three of these on your MAC or Windows OS but I would recommend grabbing a free VM via VirtualBox, loading Ubuntu on it, and doing it in Linux. It’s actually a really simple approach and you will be working in a separate environment.

So, I downloaded VirtualBox, I downloaded the 32bit version of Ubuntu, I started a New VM in VirtualBox, went into settings, storage, IDE controller, pressed plus to attach the CD image so that the VM can boot Ubuntu. It did and then I installed linux, opened the terminal, and and attached an CD and attached the downloaded Ubuntu CD image to IDE devices in my new VM and started the installation process. Once Ubuntu is installed, open the Terminal via Dash. Now, there are a couple of different ways to install NodeJS but I chose the GitHub way since I will be using GitHub for other scripts and libraries. So, first I installed git via sudo apt-get install git. I also installed two other dependencies for node: sudo apt-get install build-essential g++. Here is the github way of installing NodeJS:

git clone
cd node
git checkout v0.8.12 (or newer version if available)
sudo make install

If you run node –version you should see v0.8.12 and you are pretty much all set. Now, you could install PhantomJS by just downloading the binary (building the source takes some time) but I actually decided to leverage Node Packaged Modules. After all, PhantomJS is built for NodeJS so it makes sense (actually, that’s totally not true, see comments), and running npm install phantomjs did the trick. However, the installation did not upgrade the PATH so when I ran phantomjs –version, I got “The program ‘phantomjs’ is currently not installed” message. The good news is that fixing this problems is really easy, you just need to set a symbolic link to your local bin folder via:

sudo ln -s /home/techslides/node_modules/phantomjs/bin/phantomjs /usr/local/bin/phantomjs (change techslides to your username)

And now you can run phantomjs from anywhere. Now, it sucks that CasperJS is not in the npm registry but then again, CasperJS is for PhantomJS, so it’s not really a node module. But, you can get it via github, here are the installation instructions:

git clone git://
cd casperjs
git checkout tags/1.0.0-RC2

sudo ln -sf /home/techslides/node_modules/casperjs/bin/casperjs /usr/local/bin/casperjs (change techslides to your username)

The last command there makes CasperJS available everywhere since the Ubuntu PATH has /usr/local/bin/. And that is it, really simple. Hopefully this helps someone out there.

Facebook Twitter Hacker News Reddit More...
  • Ariya Hidayat

    Correction: PhantomJS is *not* built for Node.js. The package that you install simply downloads the binary on the fly and unpack it for you.

  • TechSlides

    Thanks Ariya, I have been only messing around with it on NodeJS so I did not realize that you can run it from anywhere. I appreciate the clarification.