如何在ubuntu上将phantomjs 1.9.8更新为phantomjs 2.1.1?

时间:2016-04-25 11:46:26

标签: ubuntu phantomjs updates reinstall

我无法在我的ubuntu 16.04上重新安装phantomjs 1.9.8到2.1.1版本 请帮忙。 1.9.8在编写旋转函数时给我一个错误,在文档中看到我可以通过重新安装解决这个问题。

6 个答案:

答案 0 :(得分:33)

我刚刚在ubuntu 16.04中使用以下步骤安装了phantomjs 2.1.1,我在谷歌搜索后找到了这些步骤:

sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo apt-get install npm
sudo npm -g install phantomjs-prebuilt

答案 1 :(得分:5)

如果我正在开发,我将如何做到这一点。这些包的版本是nodejs而不是ubuntu:

使用nvmhttps://github.com/creationix/nvm

touch ~/.profile
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash

source ~/.profile
# node 6x
nvm install 6.5.0 
npm install phantomjs@2.1.1

# node 4x
nvm install 4.5.0
nvm use 4.5.0
npm install phantomjs@1.9.19

# node 0.12x
nvm install 0.12
npm show phantomjs@* version
npm install phantomjs@1.9.8

也许我们正在0.10, 0.12, 4.X, iojs4.x, 6.X, etc开发,现在我们可以选择任何版本的幻像:

jmunsch@ubuntu:~$ npm show phantomjs@* version
phantomjs@0.0.1 '0.0.1'
phantomjs@0.0.2 '0.0.2'
phantomjs@0.0.3 '0.0.3'
phantomjs@0.0.4 '0.0.4'
phantomjs@0.0.5 '0.0.5'
phantomjs@0.0.6 '0.0.6'
phantomjs@0.0.7 '0.0.7'
phantomjs@0.0.8 '0.0.8'
phantomjs@0.0.9 '0.0.9'
phantomjs@0.1.0 '0.1.0'
phantomjs@0.1.1 '0.1.1'
phantomjs@0.2.0 '0.2.0'
phantomjs@0.2.1 '0.2.1'
phantomjs@0.2.2 '0.2.2'
phantomjs@0.2.3 '0.2.3'
phantomjs@0.2.4 '0.2.4'
phantomjs@0.2.5 '0.2.5'
phantomjs@0.2.6 '0.2.6'
phantomjs@1.9.8 '1.9.8'
phantomjs@1.9.9 '1.9.9'
phantomjs@1.9.10 '1.9.10'
phantomjs@1.9.11 '1.9.11'
phantomjs@1.9.12 '1.9.12'
phantomjs@1.9.13 '1.9.13'
phantomjs@1.9.15 '1.9.15'
phantomjs@1.9.16 '1.9.16'
phantomjs@1.9.17 '1.9.17'
phantomjs@1.9.18 '1.9.18'
phantomjs@1.9.19 '1.9.19'
phantomjs@2.1.1 '2.1.1'
phantomjs@2.1.2 '2.1.2'
phantomjs@2.1.3 '2.1.3'
phantomjs@1.9.20 '1.9.20'
phantomjs@2.1.7 '2.1.7'

系统范围的部署方案等

以下是使用tarball的方法

export PHANTOM_JS_VERSION=2.1.1
wget "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"
tar xvfj "./phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"
ln -sf "./phantomjs-$PHANTOM_JS_VERSION-linux-x86_64/bin/phantomjs" "/usr/bin"

在ubuntu 14.04上测试过,可能会将文件夹移到./以外的其他地方

更新为16.04:

wget可能有效也可能无效,请参阅:https://github.com/Medium/phantomjs/issues/161

# install dependencies
sudo apt-get install libfontconfig
# extract the tar file
tar xvfj "./phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"
# use full path
ln -sf "$(pwd)/phantomjs-$PHANTOM_JS_VERSION-linux-x86_64/bin/phantomjs" "/usr/bin"

错误

  

phantomjs:加载共享库时出错:libfontconfig.so.1:无法打开共享对象文件:没有这样的文件或目录

尝试:

 sudo apt-get install libfontconfig

答案 2 :(得分:5)

所以,jmunsch的回答对我有用,但只是为了提供一个清晰而简约的食谱:

export PHANTOM_JS_VERSION=2.1.1

sudo apt-get install libfontconfig

wget "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"

tar xvfj "./phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"

ln -sf "$(pwd)/phantomjs-$PHANTOM_JS_VERSION-linux-x86_64/bin/phantomjs" "/usr/bin"

由于/ usr / bin,最后一行需要sudo,但你可以将符号链接放在任何地方......

答案 3 :(得分:1)

对于那些像我这样安装有问题的人

比你想象的更容易......

  • 我卸载了phantomjs:从ubuntu @Component({ template: ` <h1>Cases</h1> <hr> <br> <table> <tr *ngFor="let acase of cases" > <td>{{acase.name}}</td> </tr> </table> `, }) export class CaseListComponent implements OnInit { //local variable, need to have use of this! acase: Case; cases: Case[]; constructor(public _service: CaseService, public _route: ActivatedRoute) { } ngOnInit() { this._service.getCases() .subscribe(cases => this.cases = cases); console.log(this.cases) // undefined!! } ngAfterContentInit() { console.log("cases: ", this.cases) //undefined! } } 删除phantomjs或删除sudo apt-get remove phantomjs的npm文件夹,它将在/node_modules/phantomjs中,也许你需要删除/链接ln/usr/bin中的幻像名称为/usr/local/bin/

实施例

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. 目录的npm:npm install phantomjs安装phantomjs,npm将其安装在文件夹/

实施例

/node_module/phantomjs
  • 测试文件夹

实施例

cd /;
npm install phantomjs
  • 将文件夹链接到//check version of phantomjs /node_modules/phantomjs/bin/phantomjs -v /node_modules/phantomjs/bin/phantomjs test.js

实施例

/usr/bin

  • 检查一下它的版本是否正常ln -sf /node_modules/phantomjs/bin/phantomjs /usr/bin/phantomjs在我的案例中phantomjs -v

答案 4 :(得分:1)

phantomjs 2.1.1现在与16.04(https://launchpad.net/ubuntu/xenial/+source/phantomjs)捆绑在一起,因此您应该能够将其安装/升级为系统包。

更新:此答案仅供参考,但由于以下问题,现在不推荐使用系统软件包版本:https://bugs.launchpad.net/ubuntu/+source/phantomjs/+bug/1605628这与文件问题有关上传已修复上游,但修复程序的性质阻止它作为系统包工作。

最佳当前选项是使用来自https://bitbucket.org/ariya/phantomjs/download

的预建二进制文件

答案 5 :(得分:0)

由于批准的步骤对我不起作用,我正在分享我找到的解决方案。

# Install phantomJS
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

# Sanity check 
phantomjs --version
>>> 2.1.1