steal-port
v1.1.0
Published
Kill whatever process is using a port. Reads from .env.local or .env files, or accepts a port via argument.
Readme
steal-port
A CLI tool that kills whatever process is using a port. Reads from .env.local or .env files, or accepts a port via argument.
Usage
# Kill process on port from .env.local (or .env fallback)
steal-port
# Kill process on explicit port
steal-port 3000
steal-port --port 3000
steal-port -p 3000How it works
- If a port is provided via argument, use that
- Otherwise, look for
PORT=orVITE_PORT=in.env.local(current directory) - If not found, look for
PORT=orVITE_PORT=in.env(current directory) - If no port found anywhere, exit with error
- Find and kill any process using that port
- Exit cleanly (exit 0) whether or not a process was killed
Note: PORT takes priority over VITE_PORT if both are defined.
Example package.json usage
{
"scripts": {
"dev": "steal-port && vite",
"watch": "steal-port && nest start --watch"
}
}