get-port-please
Get an available TCP port to listen
Last updated a month ago by pi0 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install get-port-please 
SYNC missed versions from official npm registry.

get-port-please

Get an available TCP port to listen

npm npm (scoped with tag)

Usage

Install package:

yarn add get-port-please
# or
or npm install get-port-please
const { getPort } = require('get-port-please')
// or
import { getPort } from 'get-port-please'
function getPort(options?: GetPortOptions): Promise<number>

Try sequence is: port > ports > memo > random

Options

interface GetPortOptions {
  name?: string

  random?: boolean
  port?: number
  ports?: number[]

  memoDir?: string
  memoName?: string
}

name

Unique name for port memorizing. Default is default.

random

If enabled, port and ports will be ignored. Default is false.

port

First port to check. Default is process.env.PORT || 3000

ports

Alternative ports to check. Default is [4000, 5000, 6000, 7000]

memoDir / memoName

Options passed to fs-memo

  • Default dir: node_modules/get-port/dist
  • Defalt name: .get-port

License

MIT

Current Tags

  • 2.1.0                                ...           latest (a month ago)

5 Versions

  • 2.1.0                                ...           a month ago
  • 2.0.0                                ...           a month ago
  • 1.1.0                                ...           2 months ago
  • 1.0.0                                ...           7 months ago
  • 0.0.6                                ...           7 months ago
Maintainers (1)
Downloads
Today 7
This Week 968
This Month 12,114
Last Day 961
Last Week 5,224
Last Month 25,833
Dependencies (1)
Dev Dependencies (6)

Copyright 2014 - 2017 © taobao.org |