New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

first-open-port

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

first-open-port

find the first open port on localhost within a range of specified ports

0.1.0
Source
npm
Version published
Weekly downloads
121
98.36%
Maintainers
1
Weekly downloads
 
Created
Source

first-open-port

Build Status Coverage Status

About | Installation | Usage | License

About

A tiny Node.js module to get the first available port on localhost in a given range. Handy for avoiding hard-coded port conflicts (EADDRINUSE) if you frequently spin up more than one local server during development. Returns a Promise.

Installation

Install and require as a standard Node module.

Install

  $ npm install --save first-open-port

Require

  var firstOpenPort = require('first-open-port')

Usage

firstOpenPort(start, max)

  • start : Number : begin search at this port
  • (max) : Number : optional last port to search before rejecting

Returns a bluebird Promise that resolves with the first open port or rejects with an error if no open ports are found in the given range.

var firstOpenPort = require('first-open-port')

firstOpenPort(3000, 3100)
  .then(port => {
    // start a server on that port
  })
  .catch(err => {
    // do something when no ports are available
  })

License

MIT

Keywords

find

FAQs

Package last updated on 21 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts