source: trip-planner-front/node_modules/portfinder/README.md@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1# node-portfinder [![Build Status](https://api.travis-ci.org/http-party/node-portfinder.svg)](https://travis-ci.org/http-party/node-portfinder)
2
3## Installation
4
5``` bash
6 $ [sudo] npm install portfinder
7```
8
9## Usage
10The `portfinder` module has a simple interface:
11
12``` js
13 var portfinder = require('portfinder');
14
15 portfinder.getPort(function (err, port) {
16 //
17 // `port` is guaranteed to be a free port
18 // in this scope.
19 //
20 });
21```
22
23Or with promise (if Promise are supported) :
24
25``` js
26 const portfinder = require('portfinder');
27
28 portfinder.getPortPromise()
29 .then((port) => {
30 //
31 // `port` is guaranteed to be a free port
32 // in this scope.
33 //
34 })
35 .catch((err) => {
36 //
37 // Could not get a free port, `err` contains the reason.
38 //
39 });
40```
41
42If `portfinder.getPortPromise()` is called on a Node version without Promise (<4), it will throw an Error unless [Bluebird](http://bluebirdjs.com/docs/getting-started.html) or any Promise pollyfill is used.
43
44### Ports search scope
45
46By default `portfinder` will start searching from `8000` and scan until maximum port number (`65535`) is reached.
47
48You can change this globally by setting:
49
50```js
51portfinder.basePort = 3000; // default: 8000
52portfinder.highestPort = 3333; // default: 65535
53```
54
55or by passing optional options object on each invocation:
56
57```js
58portfinder.getPort({
59 port: 3000, // minimum port
60 stopPort: 3333 // maximum port
61}, callback);
62```
63
64## Run Tests
65``` bash
66 $ npm test
67```
68
69#### Author: [Charlie Robbins][0]
70#### Maintainer: [Erik Trom][1]
71#### License: MIT/X11
72[0]: http://nodejitsu.com
73[1]: https://github.com/eriktrom
Note: See TracBrowser for help on using the repository browser.