• Skip to main content
  • Skip to primary sidebar

Ryan McCormick

How to Install PhantomJS 2.5 Beta on Ubuntu 14.04, 16.04 LTS

March 19, 2017 by Ryan Leave a Comment

PhantomJS is a quick, excellent alternative to native browser testing for both e2e testing with selenium and JavaScript unit testing with Karma. The beta version, PhantomJS 2.5 offers support for ES2015 unlike the current stable branch (at the time of writing this article 2.1.x).

Download PhantomJS 2.5 for Ubuntu

At the time of writing this article, the following versions are available:

  • Ubuntu 16.04 LTS (xenial)
  • Ubuntu 14.04 LTS (trusty)
  • MacOS – unsure if works on El-Capitan or Yosemite. Will find a way to verify in the future.

Download the version for your operating system from:
https://bitbucket.org/ariya/phantomjs/downloads/

Add PhantomJS to Your Path

TL;DR Advanced

The PhantomJS binary is located under the bin dir of the extracted archive. If you have a preferred way of adding things to your path, go ahead and add it. If you dont know what that means, you can follow along below.

  1. After adding to your path, verify by running which phantomjs from the command line.
  2. If everything looks good and you see the correct path, add the PHANTOMJS_BIN variable to your environment by typing export PHANTOMJS_BIN=`which phantomjs`
  3. NOTE: Make sure you use the backtick character instead of the single quote mark for the sample above!

Instructions for Adding PhantomJS to Environment

These instructions are based off of the assumption that you downloaded the PhantomJS tarball to your downloads directory.

  1. Open your terminal and make sure you are in your home dir.
  2. Type mkdir ./.phantomjs
  3. Move to your new dir cd .phantomjs
  4. Move your archive into your folder cp ~/Downloads/phantomjs-2.5.0-beta-linux-ubuntu-xenial-x86_64.tar.gz ./ (make sure you reference the correct file, as you are typing the filename, you can try hitting the tab key to autocomplete)
  5. Extract your archive tar -xvzf ./phantomjs-2.5.0-beta-linux-ubuntu-xenial-x86_64.tar.gz
  6. Rename the extracted dir mv phantomjs-2.5.0-beta-ubuntu-xenial phantomjs
  7. Change dir into the extracted phantom dir cd phantomjs
  8. Change dir into the phantom bin dir cd bin
  9. Add executable permissions chmod +x phantomjs
  10. Add to your path echo "PATH=$PATH:`pwd`" >> ~/.bashrc
  11. Close and re-open your terminal or set source: source ~/.bashrc
  12. Test by typing: phantomjs --version (at this point you should see the version. At the time of this post, 2.5.0-development).
    • If you dont get a version, you may need to add execute permissions. Browse back to the bin dir and type chmod +x ./phantomjs and try checking the version again. If you still don’t see a version number type source ~/.bashrc and type which phantomjs (you should see a path to the phantomjs bin folder)
  13. After you have verified that you are showing phantomjs 2.5+, you need to add the PHANTOMJS_BIN variable to override any other global installations. type: echo "export PHANTOMJS_BIN=`which phantomjs`" >> ~/.bashrc
  14. Close and re-open your terminal or type: source ~/.bashrc
  15. Verify PHANTOMJS_BIN var: echo $PHANTOMJS_BIN (you should see the executable path for your phantomjs 2.5).

Filed Under: ES2015, Karma, Linux/Unix Tips, Ubuntu Tagged With: angular 2, es2015, karma, phantomjs, typescript, unit testing

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Recent Posts

  • Force Quit Kill all Chrome Windows MacOS
  • SOLVED: Angular 6 CLI Karma Stuck in Single Run | Karma Stops Running
  • How to Manually Install Java 8 on Ubuntu 18.04 LTS
  • Remove VirtualBox from Ubuntu 16.04 Xenial
  • Clear all Node Modules Folders Recursively Mac/Linux

Recent Comments

  1. KKV on Webstorm adding spaces between imports and braces | JavaScript and TypeScript
  2. jusopi on Clear all Node Modules Folders Recursively Mac/Linux
  3. Qaisar Irfan on Clear all Node Modules Folders Recursively Mac/Linux
  4. mustafa on Remove VirtualBox from Ubuntu 16.04 Xenial
  5. Pourya on How to Manually Install Java 8 on Ubuntu 18.04 LTS

Copyright © 2025 · Magazine Pro on Genesis Framework · WordPress · Log in