Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pid-port

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pid-port

Get the process ID for the process that uses a certain port

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
141K
decreased by-14.75%
Maintainers
1
Weekly downloads
 
Created
Source

pid-port

Get the process ID for the process that uses a certain port

Install

$ npm install pid-port

Usage

const pidPort = require('pid-port');

(async () => {
	try {
		console.log(await pidPort.portToPid(8080));
		//=> 1337

		const pids = await pidPort.all([8080, 22]);

		console.log(pids.get(8080));
		//=> 1337

		console.log(pids.get(22));
		//=> 12345
	} catch (error) {
		console.log(error);
		//=> 'Could not find a process that uses port `8080`'
	}
})();

API

pidPort.portToPid(port)

port

Type: number

Port to look up.

pidPort.all(ports)

Returns a Promise<Map<number, number>> with the port as key and the process ID as value.

ports

Type: number[]

Ports to look up.

pidPort.list()

Get all process IDs from ports.

Returns a Promise<Map<number, number>> with the port as key and the process ID as value.

Keywords

FAQs

Package last updated on 27 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc