npm.io
2.0.0 • Published 5 months ago

lsofi

Licence
MIT
Version
2.0.0
Deps
0
Size
7 kB
Vulns
0
Weekly
0

Find processes occupying a given port

lsofi stability

npm version CI

Rationale

  • lsof -i :<port> for unix, darwin and win32 alike

Installation

npm install --save lsofi

Usage

ESM
import lsofi from 'lsofi'

const occupied = await lsofi(1337)
const free = await lsofi(1338)

console.log(occupied, free)
// => 9834 null
CommonJS
const lsofi = require('lsofi')

const occupied = await lsofi(1337)
const free = await lsofi(1338)

console.log(occupied, free)
// => 9834 null

Migration Notes

  • Minimum supported Node.js version is now 20.0.0.
  • Package now ships dual entry points using exports:
    • import lsofi from 'lsofi' (ESM)
    • require('lsofi') (CommonJS compatibility)
  • Runtime dependencies removed:
    • is-number: replaced with native Number() and Number.isFinite() validation.
    • through2: replaced with native stream parsing via readline.

See also

  • krampus - Kill processes occupying a given port

lsofi is built by marionebl and contributors. It is released under the MIT license.

Keywords