How to update phantomjs 1.9.8 to phantomjs 2.1.1 on ubuntu?

旧巷老猫 提交于 2019-12-03 07:22:42

问题


I cant reinstall phantomjs 1.9.8 to 2.1.1 version on my ubuntu 16.04 Please help. 1.9.8 give me an errors when I write a spin functions, in documentation see that this ploblem I can solve with reinstalation.


回答1:


I just installed phantomjs 2.1.1 in ubuntu 16.04 with the following steps, which I found after a bit of googling :

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



回答2:


So, jmunsch's answer works for me, but just to provide a clear and minimal recipe:

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"

The last line requires sudo because of /usr/bin, but you can put the symlink anywhere...




回答3:


Here is how I would do it if I were developing. The packages are versioned to nodejs and not ubuntu:

Use 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

Perhaps we are developing on 0.10, 0.12, 4.X, iojs4.x, 6.X, etc well now we have access to choose whichever version of 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'

system-wide for deployment scenarios, etc.

Here is how using the 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"

Tested on ubuntu 14.04, perhaps moving the folder to another place other than ./

update for 16.04:

wget may or may not work see: 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"

Error

phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

Try:

 sudo apt-get install libfontconfig



回答4:


For those who have problems to install like me

it is more easy than you think...

  • I uninstall phantomjs: Remove phantomjs from ubuntu sudo apt-get remove phantomjs or remove npm folder of /node_modules/phantomjs it will be in /, maybe you will need to remove ln the link of phantomjs in /usr/bin or /usr/local/bin/ the name of it is phantomjs

Example

//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.
  • install phantomjs from npm: npm install phantomjs from / directory, npm install it in folder /node_module/phantomjs

Example

cd /;
npm install phantomjs
  • Test bin file

Example

//check version of phantomjs
/node_modules/phantomjs/bin/phantomjs -v
/node_modules/phantomjs/bin/phantomjs test.js
  • link file bin to /usr/bin:

Example

ln -sf /node_modules/phantomjs/bin/phantomjs /usr/bin/phantomjs

  • check version of it to see if it's ok
    phantomjs -v in my case 2.1.1



回答5:


phantomjs 2.1.1 is now currently bundled with 16.04 (https://launchpad.net/ubuntu/xenial/+source/phantomjs), so you should be able to install/upgrade it as a system package.

Update: This answer exists for informative purposes, but it is not recommended to use the system package version now due to issues such as: https://bugs.launchpad.net/ubuntu/+source/phantomjs/+bug/1605628 This is related to an issue with file upload that was fixed upstream, but the nature of the fix prevented it from working as a system package.

The best current option is use the prebuilt binary from: https://bitbucket.org/ariya/phantomjs/download



来源:https://stackoverflow.com/questions/36839635/how-to-update-phantomjs-1-9-8-to-phantomjs-2-1-1-on-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!