How to install PhantomJS v2 with npm

Zen picture Zen · May 6, 2015 · Viewed 36.9k times · Source

I'm trying to install PhantomJS v2.0.0 using npm and after trying a couple of methods I've not found a working solution...

On NPM the latest version is 1.9.16, so I've tried the following in my package.json:

  1. "phantomjs": "https://github.com/ariya/phantomjs/archive/2.0.0.tar.gz"

This gives me an error because there isn't a package.json for this version in the github repo.

  1. "phantomjs": "2.0.0"

This tells me there is no version with this number available.

Am I missing something here?

Answer

Artjom B. picture Artjom B. · May 6, 2015

phantomjs-prebuilt was renamed from phantomjs and now additionally contains binaries for version 2.1+.

npm -g install phantomjs-prebuilt

The fork phantomjs2 is still available which contains version 2.0.

npm -g install phantomjs2

Keep in mind that not all platforms might be supported.