Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / phantomjs / README.md
1 phantomjs
2 ==================
3
4 An NPM installer for [PhantomJS](http://phantomjs.org/), headless webkit with JS API.
5
6 [![Build Status](https://travis-ci.org/Medium/phantomjs.svg?branch=master)](https://travis-ci.org/Medium/phantomjs)
7
8 Building and Installing
9 -----------------------
10
11 ```shell
12 npm install phantomjs
13 ```
14
15 Or grab the source and
16
17 ```shell
18 node ./install.js
19 ```
20
21 What this installer is really doing is just grabbing a particular "blessed" (by
22 this module) version of Phantom. As new versions of Phantom are released
23 and vetted, this module will be updated accordingly.
24
25 Running
26 -------
27
28 ```shell
29 bin/phantomjs [phantom arguments]
30 ```
31
32 And npm will install a link to the binary in `node_modules/.bin` as
33 it is wont to do.
34
35 Running via node
36 ----------------
37
38 The package exports a `path` string that contains the path to the
39 phantomjs binary/executable.
40
41 Below is an example of using this package via node.
42
43 ```javascript
44 var path = require('path')
45 var childProcess = require('child_process')
46 var phantomjs = require('phantomjs')
47 var binPath = phantomjs.path
48
49 var childArgs = [
50   path.join(__dirname, 'phantomjs-script.js'),
51   'some other argument (passed to phantomjs script)'
52 ]
53
54 childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
55   // handle results
56 })
57
58 ```
59
60 Versioning
61 ----------
62
63 The major and minor number tracks the version of PhantomJS that will be
64 installed. The patch number is incremented when there is either an installer
65 update or a patch build of the phantom binary.
66
67 Pre-2.0, this package was published to NPM as [phantomjs](https://www.npmjs.com/package/phantomjs).
68 We changed the name to [phantomjs](https://www.npmjs.com/package/phantomjs) at
69 the request of PhantomJS team.
70
71 Deciding Where To Get PhantomJS
72 -------------------------------
73
74 By default, this package will download phantomjs from our [releases](https://github.com/Medium/phantomjs/releases/).
75 This should work fine for most people.
76
77 ##### Downloading from a custom URL
78
79 If github is down, or the Great Firewall is blocking github, you may need to use
80 a different download mirror. To set a mirror, set npm config property `phantomjs_cdnurl`.
81
82 Alternatives include `https://bitbucket.org/ariya/phantomjs/downloads` (the official download site)
83 and `http://cnpmjs.org/downloads`.
84
85 ```Shell
86 npm install phantomjs --phantomjs_cdnurl=https://bitbucket.org/ariya/phantomjs/downloads
87 ```
88
89 Or add property into your `.npmrc` file (https://www.npmjs.org/doc/files/npmrc.html)
90
91 ```
92 phantomjs_cdnurl=https://bitbucket.org/ariya/phantomjs/downloads
93 ```
94
95 Another option is to use PATH variable `PHANTOMJS_CDNURL`.
96 ```shell
97 PHANTOMJS_CDNURL=https://bitbucket.org/ariya/phantomjs/downloads npm install phantomjs
98 ```
99
100 ##### Using PhantomJS from disk
101
102 If you plan to install phantomjs many times on a single machine, you can
103 install the `phantomjs` binary on PATH. The installer will automatically detect
104 and use that for non-global installs.
105
106 Cross-Platform Repositories
107 ---------------------------
108
109 PhantomJS needs to be compiled separately for each platform. This installer
110 finds a prebuilt binary for your operating system, and downloads it.
111
112 If you check your dependencies into git, and work on a cross-platform
113 team, then you need to tell NPM to rebuild any platform-specific dependencies. Run
114
115 ```shell
116 npm rebuild
117 ```
118
119 as part of your build process. This problem is not specific to PhantomJS, and this
120 solution will work for any NodeJS package with native or platform-specific code.
121
122 If you know in advance that you want to install PhantomJS for a specific architecture,
123 you can set the environment variables: `PHANTOMJS_PLATFORM`
124 (to set target platform) and `PHANTOMJS_ARCH` (to set target
125 arch), where `platform` and `arch` are valid values for
126 [process.platform and process.arch](https://nodejs.org/api/process.html).
127
128 A Note on PhantomJS
129 -------------------
130
131 PhantomJS is not a library for NodeJS.  It's a separate environment and code
132 written for node is unlikely to be compatible.  In particular PhantomJS does
133 not expose a Common JS package loader.
134
135 This is an _NPM wrapper_ and can be used to conveniently make Phantom available
136 It is not a Node JS wrapper.
137
138 I have had reasonable experiences writing standalone Phantom scripts which I
139 then drive from within a node program by spawning phantom in a child process.
140
141 Read the PhantomJS FAQ for more details: http://phantomjs.org/faq.html
142
143 ### Linux Note
144
145 An extra note on Linux usage, from the PhantomJS download page:
146
147  > There is no requirement to install Qt, WebKit, or any other libraries. It
148  > however still relies on Fontconfig (the package fontconfig or libfontconfig,
149  > depending on the distribution).
150
151 Troubleshooting
152 ---------------
153
154 ##### Installation fails with `spawn ENOENT`
155
156 This is NPM's way of telling you that it was not able to start a process. It usually means:
157
158 - `node` is not on your PATH, or otherwise not correctly installed.
159 - `tar` is not on your PATH. This package expects `tar` on your PATH on Linux-based platforms.
160
161 Check your specific error message for more information.
162
163 ##### Installation fails with `Error: EPERM` or `operation not permitted` or `permission denied`
164
165 This error means that NPM was not able to install phantomjs to the file system. There are three
166 major reasons why this could happen:
167
168 - You don't have write access to the installation directory.
169 - The permissions in the NPM cache got messed up, and you need to run `npm cache clean` to fix them.
170 - You have over-zealous anti-virus software installed, and it's blocking file system writes.
171
172 ##### Installation fails with `Error: read ECONNRESET` or `Error: connect ETIMEDOUT`
173
174 This error means that something went wrong with your internet connection, and the installer
175 was not able to download the PhantomJS binary for your platform. Please try again.
176
177 ##### I tried again, but I get `ECONNRESET` or `ETIMEDOUT` consistently.
178
179 Do you live in China, or a country with an authoritarian government? We've seen problems where
180 the GFW or local ISP blocks github, preventing the installer from downloading the binary.
181
182 Try visiting [the download page](https://bitbucket.org/ariya/phantomjs/downloads) manually.
183 If that page is blocked, you can try using a different CDN with the `PHANTOMJS_CDNURL`
184 env variable described above.
185
186 ##### I am behind a corporate proxy that uses self-signed SSL certificates to intercept encrypted traffic.
187
188 You can tell NPM and the PhantomJS installer to skip validation of ssl keys with NPM's 
189 [strict-ssl](https://www.npmjs.org/doc/misc/npm-config.html#strict-ssl) setting:
190
191 ```
192 npm set strict-ssl false
193 ```
194
195 WARNING: Turning off `strict-ssl` leaves you vulnerable to attackers reading
196 your encrypted traffic, so run this at your own risk!
197
198 ##### I tried everything, but my network is b0rked. What do I do?
199
200 If you install PhantomJS manually, and put it on PATH, the installer will try to
201 use the manually-installed binaries.
202
203 ##### I'm on Debian or Ubuntu, and the installer failed because it couldn't find `node`
204
205 Some Linux distros tried to rename `node` to `nodejs` due to a package
206 conflict. This is a non-portable change, and we do not try to support this. The
207 [official documentation](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#ubuntu-mint-elementary-os)
208 recommends that you run `apt-get install nodejs-legacy` to symlink `node` to `nodejs` 
209 on those platforms, or many NodeJS programs won't work properly.
210
211 Contributing
212 ------------
213
214 Questions, comments, bug reports, and pull requests are all welcome.  Submit them at
215 [the project on GitHub](https://github.com/Medium/phantomjs/).  If you haven't contributed to an
216 [Medium](http://github.com/Medium/) project before please head over to the
217 [Open Source Project](https://github.com/Medium/open-source#note-to-external-contributors) and fill
218 out an OCLA (it should be pretty painless).
219
220 Bug reports that include steps-to-reproduce (including code) are the
221 best. Even better, make them in the form of pull requests.
222
223 Author
224 ------
225
226 [Dan Pupius](https://github.com/dpup)
227 ([personal website](http://pupius.co.uk)) and
228 [Nick Santos](https://github.com/nicks), supported by
229 [A Medium Corporation](http://medium.com/).
230
231 License
232 -------
233
234 Copyright 2012 [A Medium Corporation](http://medium.com/).
235
236 Licensed under the Apache License, Version 2.0.
237 See the top-level file `LICENSE.txt` and
238 (http://www.apache.org/licenses/LICENSE-2.0).