@ajoe62/freeport-cli
v1.0.0
Published
Free up any port instantly. One command, cross-platform.
Maintainers
Readme
freeport-cli
Free up any port instantly by killing the process bound to it.
Installation
Run directly with npx:
npx freeport-cli 3000Or install globally:
npm install -g freeport-cli
freeport-cli 3000Usage
npx freeport-cli 3000
npx freeport-cli --help
npx freeport-cli --versionProgrammatic Usage
const { killPort } = require('freeport-cli');
async function run() {
const result = await killPort(3000);
console.log(result);
}
run();How It Works
- On macOS/Linux, it runs
lsof -ti tcp:{port}to find process IDs, thenkill -9 {PID}. - On Windows, it runs
netstat -ano | findstr :{port}to find process IDs, thentaskkill /PID {PID} /F. - It handles empty ports, invalid input, multi-PID scenarios, and permission errors with clear output.
Platform Support
| Platform | Supported | | --- | --- | | macOS | ? | | Linux | ? | | Windows | ? |
Contributing
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Open a pull request.
License
MIT
