{"_id":"pid-port","_rev":"3793479","name":"pid-port","description":"Get the ID of the process that uses a certain port","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2025-06-05T10:26:09.000Z","created":"2020-12-27T10:22:55.598Z","1.0.2":"2025-01-20T11:00:23.929Z","1.0.1":"2025-01-20T09:34:52.457Z","1.0.0":"2023-11-04T15:03:48.173Z","0.2.0":"2021-10-04T07:29:33.885Z","0.1.1":"2020-12-27T11:49:39.065Z","0.1.0":"2020-12-27T10:37:40.451Z","0.0.0":"2020-12-27T10:22:55.598Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/pid-port.git"},"versions":{"1.0.2":{"name":"pid-port","version":"1.0.2","description":"Get the ID of the process that uses a certain port","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/pid-port.git"},"funding":"https://github.com/sponsors/sindresorhus","type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsc index.d.ts"},"keywords":["pid","port","ports","netstat","process","processes","id","convert","converter"],"dependencies":{"execa":"^8.0.1"},"devDependencies":{"ava":"^5.3.1","get-port":"^7.0.0","typescript":"^5.2.2","xo":"^0.56.0"},"ava":{"serial":true},"_id":"pid-port@1.0.2","gitHead":"94b39c6de49e616b68f98ff42c14cf8e165a9857","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/pid-port/issues"},"homepage":"https://github.com/sindresorhus/pid-port#readme","_nodeVersion":"23.3.0","_npmVersion":"10.9.0","dist":{"shasum":"23e4dd2780b122edba3c8ff97473472225a105e5","size":3267,"noattachment":false,"key":"/pid-port/-/pid-port-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/pid-port/download/pid-port-1.0.2.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pid-port_1.0.2_1737370823747_0.8190920429416579"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-01-20T11:00:23.929Z","publish_time":1737370823929,"_source_registry_name":"default","_cnpm_publish_time":1737370823929},"1.0.1":{"name":"pid-port","version":"1.0.1","description":"Get the ID of the process that uses a certain port","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/pid-port.git"},"funding":"https://github.com/sponsors/sindresorhus","type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsc index.d.ts"},"keywords":["pid","port","ports","netstat","process","processes","id","convert","converter"],"dependencies":{"execa":"^8.0.1"},"devDependencies":{"ava":"^5.3.1","get-port":"^7.0.0","typescript":"^5.2.2","xo":"^0.56.0"},"ava":{"serial":true},"_id":"pid-port@1.0.1","gitHead":"3d3d885242d0a5aa5ef523d38e89e6bdeac7de2a","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/pid-port/issues"},"homepage":"https://github.com/sindresorhus/pid-port#readme","_nodeVersion":"23.3.0","_npmVersion":"10.9.0","dist":{"shasum":"89b17c8c0390d03981d8f70879f1928ff16ebd8a","size":3265,"noattachment":false,"key":"/pid-port/-/pid-port-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pid-port/download/pid-port-1.0.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pid-port_1.0.1_1737365692273_0.9903539501980945"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-01-20T09:34:52.457Z","publish_time":1737365692457,"_source_registry_name":"default","_cnpm_publish_time":1737365692457},"1.0.0":{"name":"pid-port","version":"1.0.0","description":"Get the ID of the process that uses a certain port","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/pid-port.git"},"funding":"https://github.com/sponsors/sindresorhus","type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsc index.d.ts"},"keywords":["pid","port","ports","netstat","process","processes","id","convert","converter"],"dependencies":{"execa":"^8.0.1"},"devDependencies":{"ava":"^5.3.1","get-port":"^7.0.0","typescript":"^5.2.2","xo":"^0.56.0"},"ava":{"serial":true},"types":"./index.d.ts","gitHead":"b851896b8b62e62149526cce5397fbfb4830dd20","bugs":{"url":"https://github.com/sindresorhus/pid-port/issues"},"homepage":"https://github.com/sindresorhus/pid-port#readme","_id":"pid-port@1.0.0","_nodeVersion":"18.18.2","_npmVersion":"9.2.0","dist":{"shasum":"b99a4d53dfeeae8b4e123d02c77e268de0413225","size":2978,"noattachment":false,"key":"/pid-port/-/pid-port-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pid-port/download/pid-port-1.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pid-port_1.0.0_1699110227931_0.4005392813691089"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-04T15:03:48.173Z","publish_time":1699110228173,"_source_registry_name":"default","_cnpm_publish_time":1699110228173},"0.2.0":{"name":"pid-port","version":"0.2.0","description":"Get the ID of the process that uses a certain port","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/pid-port.git"},"funding":"https://github.com/sponsors/sindresorhus","type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava"},"keywords":["pid","port","ports","netstat","process","processes","id","convert","converter"],"dependencies":{"execa":"^5.1.1"},"devDependencies":{"ava":"^3.15.0","get-port":"^6.0.0","xo":"^0.45.0"},"ava":{"serial":true},"gitHead":"68c99b5cf658f8228b33415d2217418bcbf5885d","bugs":{"url":"https://github.com/sindresorhus/pid-port/issues"},"homepage":"https://github.com/sindresorhus/pid-port#readme","_id":"pid-port@0.2.0","_nodeVersion":"12.22.1","_npmVersion":"7.20.3","dist":{"shasum":"db45378e4dcdb8425f911b7c09d7b0187a399873","size":2618,"noattachment":false,"key":"/pid-port/-/pid-port-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pid-port/download/pid-port-0.2.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pid-port_0.2.0_1633332573739_0.6034310099139457"},"_hasShrinkwrap":false,"publish_time":1633332573885,"_cnpm_publish_time":1633332573885},"0.1.1":{"name":"pid-port","version":"0.1.1","description":"Get the ID of the process that uses a certain port","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/pid-port.git"},"funding":{"url":"https://github.com/sponsors/sindresorhus"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava"},"keywords":["pid","port","ports","netstat","process","processes","id","convert","converter"],"dependencies":{"execa":"^5.0.0"},"devDependencies":{"ava":"^2.4.0","get-port":"^5.1.1","xo":"^0.36.1"},"gitHead":"1e0e203e45a3fcd18fcc624872ece2b4e5c613c3","bugs":{"url":"https://github.com/sindresorhus/pid-port/issues"},"homepage":"https://github.com/sindresorhus/pid-port#readme","_id":"pid-port@0.1.1","_nodeVersion":"15.5.0","_npmVersion":"7.3.0","dist":{"shasum":"2ac86fa8a0e97ef2e7eb9e7e9567cdc1eda78098","size":2347,"noattachment":false,"key":"/pid-port/-/pid-port-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pid-port/download/pid-port-0.1.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pid-port_0.1.1_1609069778936_0.8754633186563923"},"_hasShrinkwrap":false,"publish_time":1609069779065,"_cnpm_publish_time":1609069779065},"0.1.0":{"name":"pid-port","version":"0.1.0","description":"Get the ID of the process that uses a certain port","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/pid-port.git"},"funding":{"url":"https://github.com/sponsors/sindresorhus"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava"},"keywords":["pid","port","ports","netstat","process","processes","id","convert","converter"],"dependencies":{"execa":"^5.0.0"},"devDependencies":{"ava":"^2.4.0","get-port":"^5.1.1","xo":"^0.36.1"},"gitHead":"5101113a6b6b076fe002350ee4f5d895c3efc4df","bugs":{"url":"https://github.com/sindresorhus/pid-port/issues"},"homepage":"https://github.com/sindresorhus/pid-port#readme","_id":"pid-port@0.1.0","_nodeVersion":"15.5.0","_npmVersion":"7.3.0","dist":{"shasum":"cd4dfc4bdb97da34c4bd44e579d59c749e8b7527","size":2348,"noattachment":false,"key":"/pid-port/-/pid-port-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pid-port/download/pid-port-0.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pid-port_0.1.0_1609065460328_0.02418147487933875"},"_hasShrinkwrap":false,"publish_time":1609065460451,"_cnpm_publish_time":1609065460451},"0.0.0":{"name":"pid-port","version":"0.0.0","description":"Get the process ID for the process that uses a certain port","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/pid-port.git"},"funding":"https://github.com/sponsors/sindresorhus","engines":{"node":">=10"},"scripts":{"test":"xo && ava"},"keywords":["pid","port","netstat","process","processes","id"],"dependencies":{"execa":"^5.0.0"},"devDependencies":{"ava":"^2.4.0","get-port":"^5.1.1","xo":"^0.36.1"},"gitHead":"839223d39198f74db8eb981c5b1889552f8e8cf6","bugs":{"url":"https://github.com/sindresorhus/pid-port/issues"},"homepage":"https://github.com/sindresorhus/pid-port#readme","_id":"pid-port@0.0.0","_nodeVersion":"15.5.0","_npmVersion":"7.3.0","dist":{"shasum":"17a6817cfde56cd31a257111a7a0049066b591b5","size":2355,"noattachment":false,"key":"/pid-port/-/pid-port-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pid-port/download/pid-port-0.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pid-port_0.0.0_1609064575416_0.055541080327861536"},"_hasShrinkwrap":false,"publish_time":1609064575598,"_cnpm_publish_time":1609064575598}},"readme":"# pid-port\n\n> Get the ID of the process that uses a certain port\n\n## Install\n\n```sh\nnpm install pid-port\n```\n\n## Usage\n\n```js\nimport {portToPid} from 'pid-port';\n\ntry {\n\tconsole.log(await portToPid(8080));\n\t//=> 1337\n\n\tconst pids = await portToPid([8080, 22]);\n\n\tconsole.log(pids.get(8080));\n\t//=> 1337\n\n\tconsole.log(pids.get(22));\n\t//=> 12345\n} catch (error) {\n\tconsole.log(error);\n\t//=> 'Could not find a process that uses port `8080`'\n}\n```\n\n## API\n\n### portToPid(port)\n\nGet the process ID for a port.\n\nReturns a `Promise<number | undefined>` *(integer)* with the process ID.\n\n#### port\n\nType: `number` *(integer)*\n\nThe port to look up.\n\n### portToPid(ports)\n\nGet the process IDs for multiple ports.\n\nReturns a `Promise<Map<number, number>>` *(integer)* with the port as key and the process ID as value.\n\n#### ports\n\nType: `number[]` *(integer)*\n\nThe ports to look up.\n\n### pidToPorts(pid)\n\nGet the ports for a process ID.\n\nReturns a `Promise<Set<number>>` with the ports.\n\n#### pid\n\nType: `number`\n\nThe process ID to look up.\n\n### pidToPorts(pids)\n\nGet the ports for multiple process IDs.\n\nReturns a `Promise<Map<number, Set<number>>>` with the process ID as the key and the ports as value.\n\n#### pids\n\nType: `number[]`\n\nThe process IDs to look up.\n\n### allPortsWithPid()\n\nGet all ports with their process ID.\n\nReturns a `Promise<Map<number, number>>` *(integer)* with the port as key and the process ID as value.\n\n## Related\n\n- [fkill-cli](https://github.com/sindresorhus/fkill-cli) - Uses this package to let you kill the process that occupies a certain port\n- [pid-cwd](https://github.com/neeksandhu/pid-cwd) - Find the working directory of a process from its process ID\n","_attachments":{},"homepage":"https://github.com/sindresorhus/pid-port#readme","bugs":{"url":"https://github.com/sindresorhus/pid-port/issues"},"license":"MIT"}