2.1.0 • Published 13 days ago

detect-port v2.1.0

Weekly downloads
2,540,762
License
MIT
Repository
github
Last release
13 days ago

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

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.

@tuzki/scaffold-build-cli@tonyyanga/mintlify_cli@christensena/react-scriptsxuirecorderplustesting-inspectoroxygenide@asiachan/debugtstlighting-plugin-debug-modulebase-supporttest-inspectorapt-mobileapp-inspectortesting-app-inspector@omake/react-scriptsapt-mobile-inspectorcustom-react-scripts-with-modulesopinionated-react-scripts@chrissong/react-setupecarx-build@citcfe/cicli-scriptsget-clean-portdh-scripts-webreact-scripts-starterkit@gomoko/create@rari-capital/solidity-coveragebpuns-testsparrow-bird-server@ez-fe/build@ez-fe/devumo-bakery@cvpcasada/nwbegg-bin-cut@kununu/react-universal-scriptsopr-webpackreact-scripts-in-public@dh-js/scripts-reactlpp-databaseisv-lynx-devreact-scripts-by-featurereact-scripts-css-varsreact-scripts-cssm-hmrreact-scripts-pluggablereact-scripts-thtliife-modreact-storybook-scriptstdp-datamodeler@inventorjs/plugin-app-react-webpack@saaspe/components@bytebean/create@uponcommerce/createsciolareact-scripts-electron-targetkudos-climock-servicesspice-traders-cli@everything-registry/sub-chunk-1471cherry-scripts@wacoco/y@xstools-dev/toolstcrat-devtoolstangro-react-scriptstapc-plugin-publishtbd-pure-serverta-react-scriptssvelte-ssrwireit-visualizerwgtest-react-scriptsweex-nuke-devtoolweex-devtoolweex-debuggerweexpackwodax-af-webpackwocloud-scriptsweb-scriptsweb-project-buildvusionvue-block-documentationwebdriver-log-serverwebpack-vue-adminweex-previewerwenshuai-serverwork-flow-testworkbench-template-viewwpdwowschool-www-scriptsx-sm2tsservicexctest-clientxly_af-webpackxm-roadhogxestshainasharingshivens-react-scriptscalable-react-scriptssemo-plugin-serverest-ui-scriptsrebuiltronreacting-scriptsreact-web-scriptsreaction-buildreact-webextension-scripts
2.1.0

13 days ago

2.0.1

14 days ago

2.0.0

15 days ago

1.6.1

8 months ago

1.6.0

8 months ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.5.1-beta

2 years ago

1.3.0

6 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago