Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

portfinder

Package Overview
Dependencies
3
Maintainers
2
Versions
38
Issues
File Explorer

Advanced tools

portfinder

A simple tool to find an open port on the current machine

    1.0.32latest

Version published
Maintainers
2
Weekly downloads
7,603,791
decreased by-20.56%

Weekly downloads

Changelog

Source

v1.0.32

Readme

Source

node-portfinder CI

Installation

$ npm install portfinder

Usage

The portfinder module has a simple interface:

var portfinder = require('portfinder'); portfinder.getPort(function (err, port) { // // `port` is guaranteed to be a free port // in this scope. // });

Or with promise (if Promises are supported) :

const portfinder = require('portfinder'); portfinder.getPortPromise() .then((port) => { // // `port` is guaranteed to be a free port // in this scope. // }) .catch((err) => { // // Could not get a free port, `err` contains the reason. // });

If portfinder.getPortPromise() is called on a Node version without Promise (<4), it will throw an Error unless Bluebird or any Promise pollyfill is used.

Ports search scope

By default portfinder will start searching from 8000 and scan until maximum port number (65535) is reached.

You can change this globally by setting:

portfinder.setBasePort(3000); // default: 8000 portfinder.setHighestPort(3333); // default: 65535

or by passing optional options object on each invocation:

portfinder.getPort({ port: 3000, // minimum port stopPort: 3333 // maximum port }, callback);

Run Tests

$ npm test
Author: Charlie Robbins
Author/Maintainer: Erik Trom
License: MIT/X11

Keywords

FAQs

What is portfinder?

A simple tool to find an open port on the current machine

Is portfinder popular?

The npm package portfinder receives a total of 6,355,939 weekly downloads. As such, portfinder popularity was classified as popular.

Is portfinder well maintained?

We found that portfinder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.

Last updated on 13 Aug 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc