Skip to content
This repository has been archived by the owner on Aug 19, 2019. It is now read-only.

start-runner/free-port

Repository files navigation

start-free-port

npm linux build windows build coverage deps

Task for Start to find a free port from specified range.

Install

npm install --save-dev start-free-port
# or
yarn add --dev start-free-port

Usage

import start from 'start';
import reporter from 'start-pretty-reporter';
import freePort from 'start-free-port';
import * as webpack from 'start-webpack';

const minPort = 3000;
const maxPort = 3099;

export const dev = () => start(reporter())(
  freePort({ minPort, maxPort }, port => start(
    webpack.dev(require('./conf/webpack.dev'), port)
  ))
);

Arguments

freePort(options, callback)

  • options
    • minPort49152 by default
    • maxPort65535 by default
    • host'127.0.0.1' by default
  • callback – callback function which will be called with found port

List of TCP and UDP port numbers:

The range 49152–65535 contains dynamic or private ports that cannot be registered with IANA. This range is used for private, or customized services or temporary purposes and for automatic allocation of ephemeral ports.