Trying to Start Phantomjs Again 22 Cannot Start Phantomjs
phantomjs-prebuilt
An NPM installer for PhantomJS, headless webkit with JS API.
Building and Installing
npm install phantomjs-prebuilt Or grab the source and
node ./install.js What this installer is really doing is just grabbing a item "blessed" (by this module) version of Phantom. As new versions of Phantom are released and vetted, this module volition be updated appropriately.
Running
bin/phantomjs [phantom arguments] And npm will install a link to the binary in node_modules/.bin equally information technology is wont to do.
Running via node
The package exports a path cord that contains the path to the phantomjs binary/executable.
Below is an example of using this package via node.
var path = require('path') var childProcess = require('child_process') var phantomjs = require('phantomjs-prebuilt') var binPath = phantomjs.path var childArgs = [ path.join(__dirname, 'phantomjs-script.js'), 'another argument (passed to phantomjs script)' ] childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) { // handle results }) Or exec() method is also provided for convenience:
var phantomjs = require('phantomjs-prebuilt') var program = phantomjs.exec('phantomjs-script.js', 'arg1', 'arg2') program.stdout.pipage(procedure.stdout) program.stderr.piping(process.stderr) program.on('leave', lawmaking => { // do something on end }) Annotation: childProcess.spawn() is called within exec().
Running with WebDriver
run() method detects when PhantomJS gets prepare. It's handy to use with WebDriver (Selenium).
var phantomjs = require('phantomjs-prebuilt') var webdriverio = require('webdriverio') var wdOpts = { desiredCapabilities: { browserName: 'phantomjs' } } phantomjs.run('--webdriver=4444').and so(program => { webdriverio.remote(wdOpts).init() .url('https://developer.mozilla.org/en-Usa/') .getTitle().so(championship => { panel.log(title) // 'Mozilla Developer Network' program.kill() // quits PhantomJS }) }) Versioning
The major and pocket-size number tracks the version of PhantomJS that will be installed. The patch number is incremented when there is either an installer update or a patch build of the phantom binary.
Pre-2.0, this package was published to NPM every bit phantomjs. We inverse the name to phantomjs-prebuilt at the request of PhantomJS team.
Continuous Integration
Please do non download PhantomJS for every CI chore because it tin quickly overload our CDNs. Instead take reward of CI caching.
In Travis-CI add the post-obit to your .travis.yml to enable caching & avoid repeated downloads of PhantomJS.
.travis.yml
cache: directories: - travis_phantomjs before_install: # Upgrade PhantomJS to v2.ane.1. - "consign PHANTOMJS_VERSION=two.1.1" - "consign PATH=$PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin:$PATH" - "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; and so rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi" - "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then wget https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2; fi" - "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi" - "phantomjs --version" Deciding Where To Get PhantomJS
Past default, this package will download phantomjs from our releases. This should work fine for most people.
Downloading from a custom URL
If github is down, or the Great Firewall is blocking github, yous may need to use a different download mirror. To prepare a mirror, set npm config property phantomjs_cdnurl.
Alternatives include https://bitbucket.org/ariya/phantomjs/downloads (the official download site) and http://cnpmjs.org/downloads.
npm install phantomjs-prebuilt --phantomjs_cdnurl=https://bitbucket.org/ariya/phantomjs/downloads Or add property into your .npmrc file (https://www.npmjs.org/doc/files/npmrc.html)
phantomjs_cdnurl=https://bitbucket.org/ariya/phantomjs/downloads Some other option is to use PATH variable PHANTOMJS_CDNURL.
PHANTOMJS_CDNURL=https://bitbucket.org/ariya/phantomjs/downloads npm install phantomjs Using PhantomJS from disk
If yous plan to install phantomjs many times on a unmarried machine, you can install the phantomjs binary on PATH. The installer volition automatically detect and use that for non-global installs.
Cross-Platform Repositories
PhantomJS needs to exist compiled separately for each platform. This installer finds a prebuilt binary for your operating system, and downloads it.
If yous bank check your dependencies into git, and work on a cross-platform team, then you demand to tell NPM to rebuild any platform-specific dependencies. Run
npm rebuild as part of your build procedure. This trouble is non specific to PhantomJS, and this solution will piece of work for whatever NodeJS parcel with native or platform-specific code.
If y'all know in advance that you want to install PhantomJS for a specific compages, y'all can gear up the environment variables: PHANTOMJS_PLATFORM (to gear up target platform) and PHANTOMJS_ARCH (to set target arch), where platform and arch are valid values for procedure.platform and process.curvation.
A Note on PhantomJS
PhantomJS is not a library for NodeJS. It'southward a dissever environment and lawmaking written for node is unlikely to be compatible. In detail PhantomJS does not expose a Common JS package loader.
This is an NPM wrapper and can be used to conveniently brand Phantom bachelor. It is non a Node JS wrapper.
I have had reasonable experiences writing standalone Phantom scripts which I so drive from within a node plan by spawning phantom in a child process.
Read the PhantomJS FAQ for more than details: http://phantomjs.org/faq.html
Linux Note
An extra note on Linux usage, from the PhantomJS download folio:
In that location is no requirement to install Qt, WebKit, or whatever other libraries. It however however relies on Fontconfig (the package fontconfig or libfontconfig, depending on the distribution).
Troubleshooting
Installation fails with spawn ENOENT
This is NPM's manner of telling you that it was not able to starting time a process. It usually means:
-
nodeis not on your PATH, or otherwise non correctly installed. -
taris not on your PATH. This package expectstaron your PATH on Linux-based platforms. -
bzip2is not on your PATH.
Check your specific error message for more information.
Installation fails with Error: EPERM or operation not permitted or permission denied
This error means that NPM was not able to install phantomjs to the file system. There are iii major reasons why this could happen:
- You don't have write admission to the installation directory.
- The permissions in the NPM cache got messed up, and you lot need to run
npm cache cleanto fix them. - You have over-zealous anti-virus software installed, and information technology's blocking file system writes.
Installation fails with Error: read ECONNRESET or Error: connect ETIMEDOUT
This error ways that something went wrong with your internet connection, and the installer was non able to download the PhantomJS binary for your platform. Please endeavour once more.
I tried again, but I get ECONNRESET or ETIMEDOUT consistently.
Do you lot live in Red china, or a country with an authoritarian government? We've seen problems where the GFW or local ISP blocks github, preventing the installer from downloading the binary.
Try visiting the download page manually. If that page is blocked, you tin try using a different CDN with the PHANTOMJS_CDNURL env variable described to a higher place.
I am backside a corporate proxy that uses self-signed SSL certificates to intercept encrypted traffic.
You lot can tell NPM and the PhantomJS installer to skip validation of ssl keys with NPM's strict-ssl setting:
npm set strict-ssl false Alert: Turning off strict-ssl leaves you vulnerable to attackers reading your encrypted traffic, so run this at your own risk!
I tried everything, but my network is b0rked. What do I do?
If you install PhantomJS manually, and put it on PATH, the installer volition endeavor to use the manually-installed binaries.
I'k on Debian or Ubuntu, and the installer failed considering it couldn't find node
Some Linux distros tried to rename node to nodejs due to a bundle disharmonize. This is a not-portable change, and we do not try to support this. The official documentation recommends that yous run apt-become install nodejs-legacy to symlink node to nodejs on those platforms, or many NodeJS programs won't piece of work properly.
I'm using an unsupported version of Linux or an ARM processor. I get errors near "Unexpected platform or compages". What do I do?
Nosotros just have binaries bachelor for common OS / processor configurations. Sorry.
You may exist able to get a PhantomJS binary from your operating system'south package manager. Or y'all can build your own from source. If you put that binary on PATH, this installer will apply information technology (see "Deciding Where to Get PhantomJS" above).
Contributing
Questions, comments, bug reports, and pull requests are all welcome. Submit them at the project on GitHub. If y'all haven't contributed to an Medium project before delight head over to the Open up Source Project and fill out an OCLA (it should be pretty painless).
Issues reports that include steps-to-reproduce (including code) are the all-time. Even improve, make them in the form of pull requests.
Author
Dan Pupius (personal website) and Nick Santos, supported past A Medium Corporation.
License
Copyright 2012 A Medium Corporation.
Licensed under the Apache License, Version 2.0. Come across the top-level file LICENSE.txt and (http://www.apache.org/licenses/LICENSE-2.0).
Current Tags
- 2.ane.16 ... latest (4 years agone)
18 Versions
- 2.one.16 [deprecated] ... iv years ago
- 2.1.15 [deprecated] ... 5 years ago
- 2.i.14 [deprecated] ... 5 years agone
- 2.1.13 [deprecated] ... vi years agone
- 2.1.12 [deprecated] ... 6 years ago
- 2.1.12-blastoff ... 6 years ago
- 2.i.xi [deprecated] ... half dozen years ago
- 2.1.xi-blastoff.ane ... 6 years ago
- ii.1.11-alpha ... six years ago
- 2.ane.10 [deprecated] ... six years ago
- ii.ane.9 [deprecated] ... 6 years agone
- 2.1.8 [deprecated] ... six years ago
- 2.i.seven [deprecated] ... six years ago
- 2.1.6 [deprecated] ... 6 years ago
- 2.i.5 [deprecated] ... 6 years agone
- 2.1.4 [deprecated] ... 6 years ago
- 2.1.3 [deprecated] ... half dozen years agone
- 2.1.2 [deprecated] ... 6 years ago
Source: https://npmmirror.com/package/phantomjs-prebuilt
0 Response to "Trying to Start Phantomjs Again 22 Cannot Start Phantomjs"
Post a Comment