GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - node-modules/detect-port: Node.js module to detect available ports of the system.

BranchesTags
Open more actions menu

Latest commit

 

History

94 Commits
94 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.oxlintrc.json
.oxlintrc.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
COVERAGE.md
COVERAGE.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
TEST_SUMMARY.md
TEST_SUMMARY.md
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
vitest.config.ts
vitest.config.ts
 
 

Repository files navigation

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

  • ⭐⭐⭐eggjs/egg
  • ⭐⭐⭐alibaba/ice
  • ⭐⭐⭐alibaba/uirecorder
  • ⭐⭐⭐facebook/create-react-app
  • ⭐⭐⭐facebook/flipper
  • ⭐⭐⭐umijs/umi
  • ⭐⭐⭐gatsbyjs/gatsby
  • ⭐⭐⭐electron-react-boilerplate/electron-react-boilerplate
  • ⭐⭐⭐zeit/micro
  • ⭐⭐⭐rails/webpacker
  • ⭐⭐⭐storybookjs/storybook

For more

Usage

npm i detect-port

CommonJS

const { detect } = require('detect-port');

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

ESM and TypeScript

import { detect } from 'detect-port';

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

About

Node.js module to detect available ports of the system.

Topics

detectorfreenodejsport

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

394 stars

Watchers

12 watching

Forks

27 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.