Socket
Socket
Sign inDemoInstall

detect-port

Package Overview
Dependencies
3
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-port

Node.js implementation of port detector


Version published
Maintainers
3
Weekly downloads
5,820,691
decreased by-8.19%

Weekly downloads

Readme

Source

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

Keywords

FAQs

Last updated on 22 Sep 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc