Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install PhantomJS v2 with npm

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?

like image 928
Zen Avatar asked May 06 '15 18:05

Zen


People also ask

How do I know if Phantomjs is installed?

For Windows Set the PATH environment variable to the path of phantom.exe file. Open a new command prompt and type phantomjs –v. It should give you the current version of PhantomJS that is running.

How do I upgrade Phantomjs?

//use this if you installed with apt-get sudo apt-get remove phantomjs *remove the phantomjs rm /usr/bin/phantomjs *use this if the link didn't remove. //use this if you installed from npm: like this: npm install phantomjs rm -R /node_modules/phantomjs *note: it will be in other folder, search it.


2 Answers

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.

like image 173
Artjom B. Avatar answered Sep 21 '22 21:09

Artjom B.


Phantomjs may be installed as a brew package. Confirm this:

brew ls | grep phantomjs 

If you do have phantomjs installed as a brew package, you can easily uninstall it:

brew uninstall phantomjs 

Then try rerunning npm install after updating your package.json for "2.0.0".

FYI: Please read semantic versioning: https://stackoverflow.com/a/22345808/3412545

like image 43
jojo Avatar answered Sep 17 '22 21:09

jojo