Deno module to check if a port is available, get an available TCP port, or kill a process running on a port.
import {
getAvailablePort,
getAvailablePortSync,
isPortAvailable,
isPortAvailableSync,
killProcessOnPort
} from "https://deno.land/x/port/mod.ts"
Requires --allow-net
flag
Returns a promise which resolves to true
if a given port is available, else false
.
Requires --allow-net
flag
Returns true
if a given port is available, else false
.
Type: object
Required
Type: number
Type: string
Type: string
Values: tcp
Requires --allow-net
flag
Returns a promise which resolves to an available port number based on the options provided.
Requires --allow-net
flag
Returns an available port number based on the options provided.
Type: object
Type: number[] | { start: number, end: number }
If not provided, a random port will be returned
If an array of ports is provided, the first encountered available port in the array will be returned
If a range is provided, the first encountered available port in the range will be returned
Type: string
Type: string
Values: tcp
Requires --allow-run
and --allow-net
flag
Kills the process running on the given port. Returns true
if the process is killed successfully and the port is free, else false
.
Required
Type: number
deno test --allow-net mode_test.ts
MIT licensed