lsofi

Find processes occupying a given port

MIT 2 个版本
安装
npm install lsofi
yarn add lsofi
pnpm add lsofi
bun add lsofi
README

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.

版本列表
2.0.0 2026-03-13
1.0.0 2016-09-05