JSPM

  • Created
  • Published
  • Downloads 6522522
  • Score
    100M100P100Q211658F
  • License MIT

Node.js implementation of port detector

Package Exports

  • detect-port

Readme

detect-port

NPM version CI Test coverage Known Vulnerabilities npm download Node.js Version

Node.js implementation of port detector

Who are using or has used

For more

Usage

npm i detect-port
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

License

MIT

Contributors

Contributors

Made with contributors-img.