detect-port-alt

WebJar for detect-port-alt

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

detect-port-alt
Last Version

Last Version

1.1.6
Release Date

Release Date

Type

Type

jar
Description

Description

detect-port-alt
WebJar for detect-port-alt
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/node-modules/detect-port

Download detect-port-alt

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/detect-port-alt/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>detect-port-alt</artifactId>
    <version>1.1.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/detect-port-alt/
implementation 'org.webjars.npm:detect-port-alt:1.1.6'
// https://jarcasting.com/artifacts/org.webjars.npm/detect-port-alt/
implementation ("org.webjars.npm:detect-port-alt:1.1.6")
'org.webjars.npm:detect-port-alt:jar:1.1.6'
<dependency org="org.webjars.npm" name="detect-port-alt" rev="1.1.6">
  <artifact name="detect-port-alt" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='detect-port-alt', version='1.1.6')
)
libraryDependencies += "org.webjars.npm" % "detect-port-alt" % "1.1.6"
[org.webjars.npm/detect-port-alt "1.1.6"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : address jar [1.0.1,2)
org.webjars.npm : debug jar [2.6.0,3)

Project Modules

There are no modules declared in this project.

logo


NPM version build status Test coverage npm download

Node.js implementation of port detector

Who are using

For more

Usage

$ npm i detect-port --save
const detect = require('detect-port');

/**
 * callback usage
 */

detect(port, (err, _port) => {
  if (err) {
    console.log(err);
  }

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

/**
 * for a yield syntax instead of callback function implement
 */

const co = require('co');

co(function *() {
  const _port = yield detect(port);

  if (port == _port) {
    console.log(`port: ${port} was not occupied`);
  } else {
    console.log(`port: ${port} was occupied, try port: ${_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


iamyinyue

This project follows the git-contributor spec, auto updated at Tue Jul 30 2019 22:07:39 GMT+0800.

License

MIT

org.webjars.npm

node_modules

All about node.js modules like your project 'node_modules' dir

Versions

Version
1.1.6
1.1.5