{"_id":"snipe-port","_rev":"3-fddbfa09a4b0859040da8bbb62e431a6","name":"snipe-port","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"snipe-port","version":"1.0.0","keywords":["port","kill","process","cli","devtools"],"author":{"name":"Yudu Ban"},"license":"MIT","_id":"snipe-port@1.0.0","maintainers":[{"name":"banyudu","email":"banyudu@gmail.com"}],"homepage":"https://github.com/banyudu/snipe-port#readme","bugs":{"url":"https://github.com/banyudu/snipe-port/issues"},"bin":{"snipe-port":"dist/cli.js"},"dist":{"shasum":"345c4fa02cc84fb5717b21024276923ce9c9c20a","tarball":"https://registry.npmjs.org/snipe-port/-/snipe-port-1.0.0.tgz","fileCount":11,"integrity":"sha512-MZUrcExlsdYeUoO0ZaEPJc3Ckl5Yk1h4dk6Lz5XDq/BOBnlgP6S087X4b3w5zSgq8AiF1mAeCR9X/uaLZmNQaA==","signatures":[{"sig":"MEYCIQCyurLkpe1TWM3eSZ31eMHNnTgCXPyKATSNkl0gBfFfeQIhAJGycnfpawJ7VYR+h91rRg+tkAStaKPkSE9Sx13duiDy","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21737},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"a6377ea5b58685359cb480e19beaba8b5f3c8745","scripts":{"build":"tsup","prepublishOnly":"pnpm build"},"_npmUser":{"name":"banyudu","email":"banyudu@gmail.com"},"repository":{"url":"git+https://github.com/banyudu/snipe-port.git","type":"git"},"_npmVersion":"11.4.2","description":"Kill processes on a port, but only if they belong to the same project","directories":{},"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"packageManager":"pnpm@10.18.2","devDependencies":{"tsup":"^8.5.1","typescript":"^5.9.3","@types/node":"^25.3.2"},"_npmOperationalInternal":{"tmp":"tmp/snipe-port_1.0.0_1772179761036_0.07226357093593117","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"snipe-port","version":"1.0.1","keywords":["port","kill","process","cli","devtools"],"author":{"name":"Yudu Ban"},"license":"MIT","_id":"snipe-port@1.0.1","maintainers":[{"name":"banyudu","email":"banyudu@gmail.com"}],"homepage":"https://github.com/banyudu/snipe-port#readme","bugs":{"url":"https://github.com/banyudu/snipe-port/issues"},"bin":{"snipe-port":"dist/cli.js"},"dist":{"shasum":"c875b6b1699bc926fcb1163f91c9018d0f629b9b","tarball":"https://registry.npmjs.org/snipe-port/-/snipe-port-1.0.1.tgz","fileCount":12,"integrity":"sha512-KkZz5J1f1JDFQs6B+AXYxd8l1LjXqS3Mx15xA7IraUeudx9P9fbQM8aVg0tDWB2PVSDT/N4rIkTD0yB1MrnL3A==","signatures":[{"sig":"MEYCIQDHBnJnt/u3WSKBcTE3GiFJi5sI2jhv2TVeqsMEOR37PwIhAIU4blNiC/hMqCqzatVcgx65g1hVvKpsLhIiQDDQWGGf","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23882},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"9f1656034334dd8c3fe3d72cf00a38dd367450c0","scripts":{"build":"tsup","prepublishOnly":"pnpm build"},"_npmUser":{"name":"banyudu","email":"banyudu@gmail.com"},"repository":{"url":"git+https://github.com/banyudu/snipe-port.git","type":"git"},"_npmVersion":"11.4.2","description":"Kill processes on a port, but only if they belong to the same project","directories":{},"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"packageManager":"pnpm@10.18.2","devDependencies":{"tsup":"^8.5.1","typescript":"^5.9.3","@types/node":"^25.3.2"},"_npmOperationalInternal":{"tmp":"tmp/snipe-port_1.0.1_1773547473250_0.46279564117816085","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"snipe-port","version":"1.0.2","description":"Kill processes on a port, but only if they belong to the same project","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"bin":{"snipe-port":"dist/cli.js"},"keywords":["port","kill","process","cli","devtools"],"author":{"name":"Yudu Ban"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/banyudu/snipe-port.git"},"devDependencies":{"@types/node":"^25.3.2","tsup":"^8.5.1","typescript":"^5.9.3"},"scripts":{"build":"tsup"},"_id":"snipe-port@1.0.2","bugs":{"url":"https://github.com/banyudu/snipe-port/issues"},"homepage":"https://github.com/banyudu/snipe-port#readme","_integrity":"sha512-1qBxqoql7g9I6LyQye2jF1FNDzfOP90EMcfbIOqWsTQeBrCDUROqO5O+Fi0lUhxrATSd1inL+ImhvmX2vMxwyw==","_resolved":"/private/var/folders/lm/ht8g7bb11ll6k8q5c1dhh99r0000gn/T/b7afa41943a91d602e921cc781a2d541/snipe-port-1.0.2.tgz","_from":"file:snipe-port-1.0.2.tgz","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-1qBxqoql7g9I6LyQye2jF1FNDzfOP90EMcfbIOqWsTQeBrCDUROqO5O+Fi0lUhxrATSd1inL+ImhvmX2vMxwyw==","shasum":"2964f277e414579b00609ef22c21c083c242b30d","tarball":"https://registry.npmjs.org/snipe-port/-/snipe-port-1.0.2.tgz","fileCount":12,"unpackedSize":24103,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDzx2qdFu8tIK/5nOSNTFzY5AhzISADNSwQ+wYRYp8fPAiEA6Suk5vLlNLWdVQ9Qw3CIwoxQqSGm4wJ3YU3x4gDwejQ="}]},"_npmUser":{"name":"banyudu","email":"banyudu@gmail.com"},"directories":{},"maintainers":[{"name":"banyudu","email":"banyudu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/snipe-port_1.0.2_1773582341506_0.6968622369888549"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-27T08:09:21.034Z","modified":"2026-03-15T13:45:41.810Z","1.0.0":"2026-02-27T08:09:21.176Z","1.0.1":"2026-03-15T04:04:33.401Z","1.0.2":"2026-03-15T13:45:41.674Z"},"bugs":{"url":"https://github.com/banyudu/snipe-port/issues"},"author":{"name":"Yudu Ban"},"license":"MIT","homepage":"https://github.com/banyudu/snipe-port#readme","keywords":["port","kill","process","cli","devtools"],"repository":{"type":"git","url":"git+https://github.com/banyudu/snipe-port.git"},"description":"Kill processes on a port, but only if they belong to the same project","maintainers":[{"name":"banyudu","email":"banyudu@gmail.com"}],"readme":"# snipe-port\n\nKill processes on a port, but only if they belong to the same project.\n\nUnlike `kill-port` or `fkill`, snipe-port checks that the process shares the same working directory or git repo (including worktrees) before killing it. This prevents accidentally killing unrelated processes during development.\n\n## Install\n\n```bash\nnpm i -g snipe-port\n```\n\n## Usage\n\n### CLI\n\n```bash\nsnipe-port 3000           # kill process on port 3000 (if same project)\nsnipe-port 3000 8080      # multiple ports\nsnipe-port -p 3000        # --port flag\nsnipe-port -9 3000        # force kill (SIGKILL)\nsnipe-port --udp 3000     # target UDP instead of TCP\n```\n\n### Programmatic API\n\n```ts\nimport { snipePort } from 'snipe-port'\n\n// Kill process on port 3000 (returns array of killed PIDs)\nconst killed = await snipePort(3000)\n\n// Force kill with SIGKILL\nconst killed = await snipePort(3000, { signal: 'SIGKILL' })\n\n// Target UDP\nconst killed = await snipePort(3000, { method: 'udp' })\n```\n\n## How it works\n\n1. **Find PIDs** on the given port using `lsof` (macOS/Linux)\n2. **Resolve working directory** of each process (`lsof -d cwd` on macOS, `/proc/PID/cwd` on Linux)\n3. **Check project membership** — the process is considered part of the same project if:\n   - Its working directory matches the current directory, OR\n   - It shares the same git repository root (including git worktrees)\n4. **Kill** only matching processes with `SIGTERM` (or `SIGKILL` with `-9`)\n\n## Why?\n\nDuring development you often restart servers and need to free up a port. Tools like `kill-port` will kill *any* process on that port — including a database, another project's dev server, or a production process you didn't mean to touch.\n\nsnipe-port scopes the kill to your current project, so it's safe to use without thinking twice.\n\n## Options\n\n| Flag | Description |\n|------|-------------|\n| `-p, --port <port>` | Specify port(s) to kill |\n| `-9, --force` | Force kill with SIGKILL |\n| `--udp` | Target UDP instead of TCP |\n| `-h, --help` | Show help |\n| `-v, --version` | Show version |\n\n## Requirements\n\n- Node.js >= 14\n- macOS or Linux (`lsof` required)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}