{"id":13396569,"url":"https://github.com/node-modules/detect-port","last_synced_at":"2025-06-14T03:07:36.748Z","repository":{"id":41274886,"uuid":"36540283","full_name":"node-modules/detect-port","owner":"node-modules","description":"Node.js module to detect available ports of the system.","archived":false,"fork":false,"pushed_at":"2024-12-11T02:27:19.000Z","size":126,"stargazers_count":389,"open_issues_count":1,"forks_count":25,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-06-08T21:46:38.760Z","etag":null,"topics":["detector","free","nodejs","port"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-modules.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-30T02:50:53.000Z","updated_at":"2025-05-26T08:59:49.000Z","dependencies_parsed_at":"2025-02-05T22:11:18.270Z","dependency_job_id":"3f6a4220-d687-41b9-b2b6-09a5aee9bc76","html_url":"https://github.com/node-modules/detect-port","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/node-modules/detect-port","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fdetect-port","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fdetect-port/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fdetect-port/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fdetect-port/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-modules","download_url":"https://codeload.github.com/node-modules/detect-port/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fdetect-port/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259752078,"owners_count":22905972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["detector","free","nodejs","port"],"created_at":"2024-07-30T18:00:57.093Z","updated_at":"2025-06-14T03:07:36.723Z","avatar_url":"https://github.com/node-modules.png","language":"TypeScript","readme":"# detect-port\n\n[![NPM version][npm-image]][npm-url]\n[![CI](https://github.com/node-modules/detect-port/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/detect-port/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n[![Node.js Version][node-version-image]][node-version-url]\n\n[npm-image]: https://img.shields.io/npm/v/detect-port.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/detect-port\n[codecov-image]: https://codecov.io/gh/node-modules/detect-port/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/node-modules/detect-port\n[snyk-image]: https://snyk.io/test/npm/detect-port/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/detect-port\n[download-image]: https://img.shields.io/npm/dm/detect-port.svg?style=flat-square\n[download-url]: https://npmjs.org/package/detect-port\n[node-version-image]: https://img.shields.io/node/v/detect-port.svg?style=flat-square\n[node-version-url]: https://nodejs.org/en/download/\n\n\u003e Node.js implementation of port detector\n\n## Who are using or has used\n\n- ⭐⭐⭐[eggjs/egg](//github.com/eggjs/egg)\n- ⭐⭐⭐[alibaba/ice](//github.com/alibaba/ice)\n- ⭐⭐⭐[alibaba/uirecorder](//github.com/alibaba/uirecorder)\n- ⭐⭐⭐[facebook/create-react-app](//github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/package.json)\n- ⭐⭐⭐[facebook/flipper](//github.com/facebook/flipper)\n- ⭐⭐⭐[umijs/umi](//github.com/umijs/umi)\n- ⭐⭐⭐[gatsbyjs/gatsby](//github.com/gatsbyjs/gatsby)\n- ⭐⭐⭐[electron-react-boilerplate/electron-react-boilerplate](//github.com/electron-react-boilerplate/electron-react-boilerplate)\n- ⭐⭐⭐[zeit/micro](//github.com/zeit/micro)\n- ⭐⭐⭐[rails/webpacker](//github.com/rails/webpacker)\n- ⭐⭐⭐[storybookjs/storybook](//github.com/storybookjs/storybook)\n\n[For more](//github.com/node-modules/detect-port/network/dependents)\n\n## Usage\n\n```bash\nnpm i detect-port\n```\n\nCommonJS\n\n```javascript\nconst { detect } = require('detect-port');\n\ndetect(port)\n  .then(realPort =\u003e {\n    if (port == realPort) {\n      console.log(`port: ${port} was not occupied`);\n    } else {\n      console.log(`port: ${port} was occupied, try port: ${realPort}`);\n    }\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n\nESM and TypeScript\n\n```ts\nimport { detect } from 'detect-port';\n\ndetect(port)\n  .then(realPort =\u003e {\n    if (port == realPort) {\n      console.log(`port: ${port} was not occupied`);\n    } else {\n      console.log(`port: ${port} was occupied, try port: ${realPort}`);\n    }\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n\n## Command Line Tool\n\n```bash\nnpm i detect-port -g\n```\n\n### Quick Start\n\n```bash\n# get an available port randomly\n$ detect\n\n# detect pointed port\n$ detect 80\n\n# output verbose log\n$ detect --verbose\n\n# more help\n$ detect --help\n```\n\n## FAQ\n\nMost likely network error, check that your `/etc/hosts` and make sure the content below:\n\n```bash\n127.0.0.1       localhost\n255.255.255.255 broadcasthost\n::1             localhost\n```\n\n## License\n\n[MIT](LICENSE)\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=node-modules/detect-port)](https://github.com/node-modules/detect-port/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","funding_links":[],"categories":["http","Repository","工具类库","JavaScript"],"sub_categories":["Network"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Fdetect-port","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-modules%2Fdetect-port","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Fdetect-port/lists"}