npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fnet/port-killer

v0.1.5

Published

This utility serves a straightforward purpose: it identifies and terminates any process running on a specified network port. It's useful for developers and system administrators who need to effortlessly free up ports for new applications or processes.

Downloads

13

Readme

@fnet/port-killer

This utility serves a straightforward purpose: it identifies and terminates any process running on a specified network port. It's useful for developers and system administrators who need to effortlessly free up ports for new applications or processes.

How It Works

The tool checks your system for any running process that is using a defined port number. If it finds a process, it will terminate it. If no process is using the port, it will simply inform you that no action was taken.

Key Features

  • Detects processes running on a specified port.
  • Terminates identified processes to free up the port.
  • Compatible with Windows, macOS, and Linux operating systems.

Conclusion

@fnet/port-killer is a handy tool to quickly check and clear ports on your system without needing to manually find or end processes, streamlining your workflow.

@fnet/port-killer Developer Guide

Overview

The @fnet/port-killer library is a simple Node.js utility designed to help developers terminate processes running on a specific port. This can be particularly useful during development when ports need to be freed for new processes. The library provides a straightforward public API that allows you to identify and terminate processes using specified ports on different operating systems.

Installation

To install the @fnet/port-killer library, use either npm or yarn. Here are the installation commands:

Using npm:

npm install @fnet/port-killer

Using yarn:

yarn add @fnet/port-killer

Usage

The primary functionality of the @fnet/port-killer library is encapsulated in its default exported function. Here’s how you can use it in your Node.js applications:

Importing and Using the Library

import killPort from '@fnet/port-killer';

// Specify the port number you wish to free
const portToKill = 3000;

// Attempt to kill the process using the specified port
killPort({ port: portToKill })
  .then(message => console.log(message))
  .catch(error => console.error(error));

This code snippet imports the killPort function from the library, specifies a port (e.g., 3000), and attempts to terminate any process currently using that port. If successful, it logs a success message; otherwise, it logs an error.

Examples

Here are practical examples of using the @fnet/port-killer library:

Kill a Process on Port 8080

import killPort from '@fnet/port-killer';

killPort({ port: 8080 })
  .then(message => console.log(message)) // Output: "Process on port 8080 killed successfully." or "No process found on port 8080. Skipping kill command."
  .catch(error => console.error(error));

Handle Errors Gracefully

import killPort from '@fnet/port-killer';

killPort({ port: 1234 })
  .then(message => console.log(message))
  .catch(error => {
    // Handle specific errors or log them for debugging purposes
    console.error(`Failed to kill process: ${error}`);
  });

These examples demonstrate how the library is used to detect and terminate processes on specified ports, complete with error handling and messaging for different scenarios.

Acknowledgement

We acknowledge the use of Node.js core modules in building this utility. The library's functionality handles platform-specific commands to achieve process termination across different operating systems.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  port:
    type: integer
    description: The port number to check and kill the process for.
required:
  - port