detect-port
detect available port
Last updated 8 years ago by xudafeng .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install detect-port 
SYNC missed versions from official npm registry.

logo


NPM version build status Test coverage npm download

Node.js implementation of port detector

Who are using or has used

For more

Usage

$ npm i detect-port --save
const detect = require('detect-port');
/**
 * use as a promise
 */

detect(port)
  .then(_port => {
    if (port == _port) {
      console.log(`port: ${port} was not occupied`);
    } else {
      console.log(`port: ${port} was occupied, try port: ${_port}`);
    }
  })
  .catch(err => {
    console.log(err);
  });

Command Line Tool

$ npm i detect-port -g

Quick Start

# get an available port randomly
$ detect

# detect pointed port
$ detect 80

# output verbose log
$ detect --verbose

# more help
$ detect --help

FAQ

Most likely network error, check that your /etc/hosts and make sure the content below:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

Contributors


xudafeng


fengmk2


ziczhu


gaearon


chnliquan


popomore


snapre


yavuzakyuz


antife-yinyue

This project follows the git-contributor spec, auto updated at Wed Sep 21 2022 23:10:27 GMT+0800.

License

MIT

Current Tags

  • 2.1.0                                ...           latest (16 days ago)
  • 1.6.1                                ...           release-1.x (8 months ago)

33 Versions

  • 2.1.0                                ...           16 days ago
  • 2.0.1                                ...           17 days ago
  • 2.0.0                                ...           18 days ago
  • 1.6.1                                ...           8 months ago
  • 1.6.0                                ...           8 months ago
  • 1.5.1                                ...           2 years ago
  • 1.5.1-beta                                ...           2 years ago
  • 1.5.0                                ...           2 years ago
  • 1.4.1                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.0                                ...           6 years ago
  • 1.2.3                                ...           7 years ago
  • 1.2.2                                ...           7 years ago
  • 1.2.1                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.4                                ...           8 years ago
  • 1.1.3                                ...           8 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.7                                ...           8 years ago
  • 1.0.6                                ...           8 years ago
  • 1.0.5                                ...           8 years ago
  • 1.0.4                                ...           8 years ago
  • 1.0.3                                ...           8 years ago
  • 1.0.2                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.1.4                                ...           9 years ago
  • 0.1.3                                ...           9 years ago
  • 0.1.2                                ...           10 years ago
  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
Maintainers (2)
Downloads
Total 35
Today 0
This Week 0
This Month 33
Last Day 0
Last Week 33
Last Month 0
Dependencies (0)
None
Dev Dependencies (7)

© 2010 - cnpmjs.org x YWFE | Home | YWFE