1. detect-port
Node.js implementation of port detector
detect-port
Package: detect-port
Created by: node-modules
Last modified: Thu, 22 Sep 2022 11:06:21 GMT
Version: 1.5.1
License: MIT
Downloads: 25,152,094
Repository: https://github.com/node-modules/detect-port

Install

npm install detect-port
yarn add detect-port

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

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin