port_check_kill
v1.0.21
Published
A lightweight Node.js utility to check if a specific port is free and optionally **terminate any running service** on that port.
Readme
📦 Port Check Utility (Node.js)
A lightweight Node.js utility to check if a specific port is free and optionally terminate any running service on that port.
✅ Installation
Install this package in your project:
npm install port_check_kill🚀 Usage
📌 Check if a port is free:
isPortFree(port_number);Example:
isPortFree(3000);🔥 Force kill service on a busy port:
isPortFree(port_number, 'quit');If the port is already in use, this will kill the process and free the port.
Example:
isPortFree(3000, 'quit');📚 Importing the Utility
CommonJS
const { isPortFree, how_to_run } = require('port_check_kill');ES Modules
import { isPortFree, how_to_run } from 'port_check_kill';call how_to_run()
to know how to work with functions
⚠️ Notes
- On macOS/Linux, ensure
lsofandkillare available (they are available by default). - If the kill command fails, try running your script with
sudo.
🛠️ Functions
isPortFree(port, mode?)
port(Number) – The port number to check.mode(Optional String) – Pass'quit'to forcefully kill the process using the port.
📜 License
MIT © 2025 adarshtech251
