| | |
| | | ``` |
| | | |
| | | ```js |
| | | const { getPort } = require('get-port-please') |
| | | // or |
| | | import { getPort } from 'get-port-please' |
| | | // ESM |
| | | import { getPort, checkPort, getRandomPort, waitForPort } from 'get-port-please' |
| | | |
| | | // CommonJS |
| | | const { getPort, checkPort, getRandomPort, waitForPort } = require('get-port-please') |
| | | ``` |
| | | |
| | | ```ts |
| | | function getPort(options?: GetPortOptions): Promise<number> |
| | | getPort(options?: GetPortOptions): Promise<number> |
| | | checkPort(port: number, host?: string): Promise<number | false> |
| | | waitForPort(port: number, options): Promise<number | false> |
| | | ``` |
| | | |
| | | Try sequence is: port > ports > memo > random |
| | |
| | | |
| | | random?: boolean |
| | | port?: number |
| | | portRange?: [from: number, to: number] |
| | | ports?: number[] |
| | | host?: string |
| | | |
| | |
| | | |
| | | ### `ports` |
| | | |
| | | Alternative ports to check. Default is `[4000, 5000, 6000, 7000]` |
| | | Alternative ports to check. |
| | | |
| | | ### `portRange` |
| | | |
| | | Alternative port range to check. Deefault is `[3000,3100]` |
| | | |
| | | ### `host` |
| | | |
| | | The host to check. Default is `process.env.HOST || '0.0.0.0'` |
| | | The host to check. Default is `process.env.HOST` otherwise all available hosts will be checked. |
| | | |
| | | ### `memoDir` / `memoName` |
| | | |