node.js 如何使用 npm 安装 PhantomJS v2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30084690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:44:21  来源:igfitidea点击:

How to install PhantomJS v2 with npm

node.jsgithubnpmphantomjs

提问by Zen

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

我正在尝试v2.0.0使用PhantomJS 安装 PhantomJS npm,在尝试了几种方法后,我还没有找到可行的解决方案......

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

在 NPM 上,最新版本是1.9.16,所以我在我的中尝试了以下内容package.json

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

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

这给了我一个错误,因为package.jsongithub 存储库中没有此版本。

  1. "phantomjs": "2.0.0"
  1. "phantomjs": "2.0.0"

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

这告诉我没有可用此编号的版本。

Am I missing something here?

我在这里错过了什么吗?

回答by Artjom B.

phantomjs-prebuiltwas renamed from phantomjsand now additionally contains binaries for version 2.1+.

phantomjs-prebuiltphantomjs重命名,现在还包含 2.1+ 版本的二进制文件。

npm -g install phantomjs-prebuilt

The fork phantomjs2is still available which contains version 2.0.

fork phantomjs2仍然可用,其中包含版本 2.0。

npm -g install phantomjs2

Keep in mind that not all platforms might be supported.

请记住,并非所有平台都受支持。

回答by jojo

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

Phantomjs 可以作为 brew 包安装。确认这一点:

brew ls | grep phantomjs

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

如果您确实将 phantomjs 作为 brew 包安装,则可以轻松卸载它:

brew uninstall phantomjs

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

然后npm install在将 package.json 更新为“2.0.0”后尝试重新运行。

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

仅供参考:请阅读语义版本控制:https: //stackoverflow.com/a/22345808/3412545

回答by maxime1992

I had troubles to install it via npm.

我在通过 npm 安装它时遇到了麻烦。

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

我决定建造它。我正在运行 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

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

然后下载源代码:https: //bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.0.0-source.zip

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

并运行:
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.

构建它是一个非常漫长的过程!确保你知道你在做什么。

回答by Goodlife

npm install phantomjs-prebuilttry this for node users

npm install phantomjs-prebuilt为节点用户试试这个