How to install PhantomJS v2 with npm

2019-02-11 10:56发布

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?

4条回答
forever°为你锁心
2楼-- · 2019-02-11 11:35

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

查看更多
时光不老,我们不散
3楼-- · 2019-02-11 11:39

I had troubles to install it via npm.

I decided to build it. I'm running Ubuntu 15.10.

First, check you have all the development packages installed :

sudo apt-get install build-essential g++ flex bison gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libpng-dev libjpeg-dev python libx11-dev libxext-dev

Then download the source code : https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.0.0-source.zip

And run :
cd phantomjs-2.0.0-source sudo ./build.sh

It's a very long process to build it ! Be sure you know what you're doing.

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-02-11 11:41

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.

查看更多
Evening l夕情丶
5楼-- · 2019-02-11 11:44

npm install phantomjs-prebuilt try this for node users

查看更多
登录 后发表回答