如何在 ubuntu 上将 phantomjs 1.9.8 更新为 phantomjs 2.1.1?
How to update phantomjs 1.9.8 to phantomjs 2.1.1 on ubuntu?
我无法在 ubuntu 16.04 上将 phantomjs 1.9.8 重新安装到 2.1.1 版本
请帮忙。
1.9.8 在我写自旋函数时报错,在文档中看到这个问题我可以通过重新安装来解决。
我刚刚通过以下步骤在 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
如果我正在开发,这就是我会怎么做。这些包版本控制到 nodejs 而不是 ubuntu:
使用nvm
:https://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
上开发,现在我们可以选择 phantomjs 的任何版本:
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: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory
尝试:
sudo apt-get install libfontconfig
对于像我一样安装有问题的人
它比你想象的要容易...
- 我卸载 phantomjs:从 ubuntu
sudo apt-get remove phantomjs
中删除 phantomjs 或删除 /node_modules/phantomjs
的 npm 文件夹,它将位于 /
,也许您需要删除 ln
/usr/bin
或 /usr/local/bin/
中 phantomjs 的 link 它的名字是 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 安装 phantomjs:
npm install phantomjs
从 /
目录,npm 安装在文件夹 /node_module/phantomjs
例子
cd /;
npm install phantomjs
- 测试bin文件
例子
//check version of phantomjs
/node_modules/phantomjs/bin/phantomjs -v
/node_modules/phantomjs/bin/phantomjs test.js
- link 文件箱到
/usr/bin
:
例子
ln -sf /node_modules/phantomjs/bin/phantomjs /usr/bin/phantomjs
- 检查版本是否正常
phantomjs -v
就我而言 2.1.1
所以,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,但您可以将符号链接放在任何地方...
phantomjs 2.1.1 目前与 16.04 (https://launchpad.net/ubuntu/xenial/+source/phantomjs) 捆绑在一起,因此您应该能够 install/upgrade 它作为系统包。
更新:此答案仅供参考,但不推荐使用系统包版本,原因如下:https://bugs.launchpad.net/ubuntu/+source/phantomjs/+bug/1605628这是相关的上游修复的文件上传问题,但修复的性质阻止它作为系统包工作。
当前最好的选择是使用预构建的二进制文件:https://bitbucket.org/ariya/phantomjs/download
由于批准的步骤对我不起作用,我将分享我找到的解决方案。
# 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
我无法在 ubuntu 16.04 上将 phantomjs 1.9.8 重新安装到 2.1.1 版本 请帮忙。 1.9.8 在我写自旋函数时报错,在文档中看到这个问题我可以通过重新安装来解决。
我刚刚通过以下步骤在 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
如果我正在开发,这就是我会怎么做。这些包版本控制到 nodejs 而不是 ubuntu:
使用nvm
:https://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
上开发,现在我们可以选择 phantomjs 的任何版本:
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: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory
尝试:
sudo apt-get install libfontconfig
对于像我一样安装有问题的人
它比你想象的要容易...
- 我卸载 phantomjs:从 ubuntu
sudo apt-get remove phantomjs
中删除 phantomjs 或删除/node_modules/phantomjs
的 npm 文件夹,它将位于/
,也许您需要删除ln
/usr/bin
或/usr/local/bin/
中 phantomjs 的 link 它的名字是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 安装 phantomjs:
npm install phantomjs
从/
目录,npm 安装在文件夹/node_module/phantomjs
例子
cd /;
npm install phantomjs
- 测试bin文件
例子
//check version of phantomjs
/node_modules/phantomjs/bin/phantomjs -v
/node_modules/phantomjs/bin/phantomjs test.js
- link 文件箱到
/usr/bin
:
例子
ln -sf /node_modules/phantomjs/bin/phantomjs /usr/bin/phantomjs
- 检查版本是否正常
phantomjs -v
就我而言2.1.1
所以,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,但您可以将符号链接放在任何地方...
phantomjs 2.1.1 目前与 16.04 (https://launchpad.net/ubuntu/xenial/+source/phantomjs) 捆绑在一起,因此您应该能够 install/upgrade 它作为系统包。
更新:此答案仅供参考,但不推荐使用系统包版本,原因如下:https://bugs.launchpad.net/ubuntu/+source/phantomjs/+bug/1605628这是相关的上游修复的文件上传问题,但修复的性质阻止它作为系统包工作。
当前最好的选择是使用预构建的二进制文件:https://bitbucket.org/ariya/phantomjs/download
由于批准的步骤对我不起作用,我将分享我找到的解决方案。
# 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