web-dev-qa-db-fra.com

Comment mettre à jour phantomjs 1.9.8 à phantomjs 2.1.1 sur Ubuntu?

Je ne peux pas réinstaller la version 1.9.8 à 2.1.1 de phantomjs sur mon Ubuntu 16.04 S'il vous plaît, aidez-moi. 1.9.8 me donne une erreur quand j'écris un spin fonctions, dans la documentation voir que ce problème je peux résoudre avec reinstalation.

13
Andrzej Moroz

Je viens d'installer phantomjs 2.1.1 dans Ubuntu 16.04 avec les étapes suivantes, que j'ai trouvées après un peu de recherche sur Google:

Sudo apt-get install nodejs
Sudo apt-get install nodejs-legacy
Sudo apt-get install npm
Sudo npm -g install phantomjs-prebuilt
32
dmdip

Voici comment je le ferais si je développais. Les paquets sont versionnés dans nodejs et non pas dans Ubuntu:

Utilisez 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 [email protected]

# node 4x
nvm install 4.5.0
nvm use 4.5.0
npm install [email protected]

# node 0.12x
nvm install 0.12
npm show phantomjs@* version
npm install [email protected]

Nous développons peut-être sur 0.10, 0.12, 4.X, iojs4.x, 6.X, etc et maintenant nous avons le choix de choisir la version de phantomjs:

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

à l'échelle du système pour les scénarios de déploiement, etc.

Voici comment utiliser la 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"

Testé sur Ubuntu 14.04, peut-être en déplaçant le dossier dans un endroit autre que ./

mise à jour pour 16.04:

wget peut ou peut ne pas fonctionner voir: 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"

Erreur

phantomjs: erreur lors du chargement des bibliothèques partagées: libfontconfig.so.1: impossible d'ouvrir le fichier objet partagé: aucun fichier ou répertoire de ce type

Essayer:

 Sudo apt-get install libfontconfig
5
jmunsch

Donc, la réponse de jmunsch fonctionne pour moi, mais juste pour fournir une recette claire et minimale:

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"

La dernière ligne nécessite Sudo à cause de/usr/bin, mais vous pouvez placer le lien symbolique n'importe où ...

5

actuellement, phantomjs 2.1.1 est fourni avec 16.04 ( https://launchpad.net/ubuntu/xenial/+source/phantomjs ), vous devriez donc pouvoir l’installer/le mettre à niveau en tant que package système.

Mise à jour: cette réponse existe à titre informatif, mais il est non recommandé d'utiliser la version de package système maintenant en raison de problèmes tels que: https://bugs.launchpad.net/ubuntu/+source/ phantomjs/+ bug/1605628 Ceci est lié à un problème de téléchargement de fichier qui a été corrigé en amont, mais la nature du correctif l'a empêché de fonctionner comme un package système. 

La meilleure option actuelle est d'utiliser le binaire pré-construit à partir de: https://bitbucket.org/ariya/phantomjs/download

1
prusswan

Pour ceux qui ont des problèmes à installer comme moi

c'est plus facile que vous ne le pensez ...

  • Je désinstalle phantomjs: Supprimez phantomjs de ubuntu Sudo apt-get remove phantomjs ou supprimez le dossier npm de /node_modules/phantomjs il sera dans /, vous devrez peut-être supprimer ln le lien de phantomjs dans /usr/bin ou /usr/local/bin/ dont le nom est phantomjs

Exemple

//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.
  • installez phantomjs à partir de npm: npm install phantomjs à partir du répertoire /, npm installez-le dans le dossier /node_module/phantomjs

Exemple

cd /;
npm install phantomjs
  • Fichier bin de test

Exemple

//check version of phantomjs
/node_modules/phantomjs/bin/phantomjs -v
/node_modules/phantomjs/bin/phantomjs test.js
  • lier le fichier bin à /usr/bin:

Exemple

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

  • vérifier la version pour voir si ça va
    phantomjs -v dans mon cas 2.1.1
1
DarckBlezzer