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 🙏

© 2026 – Pkg Stats / Ryan Hefner

terminal-port-manager

v1.0.6

Published

A Next.js component for managing terminal ports and processes. This package provides an easy way to check port availability and manage processes using those ports.

Downloads

6

Readme

Terminal Port Manager

A Next.js component for managing terminal ports and processes. This package provides an easy way to check port availability and manage processes using those ports.

Installation

npm install terminal-port-manager
# or
yarn add terminal-port-manager
# or
bun add terminal-port-manager

Features

  • Automatic port checking
  • Process management
  • Built-in Next.js page component
  • TypeScript support
  • Zero configuration required

How It Works

Detect Project Structure:
    The findTargetStructure function checks for the existence of directories like app/api, src/app/api, pages/api, and src/pages/api.
    It returns the first matching structure or defaults to app router.

Process Files:
    For API routes, it generates the file dynamically from the content string.
    For page components, it copies the file from the package to the appropriate directory.

Create Folders if Missing:
    If the required directories don’t exist (e.g., app/api), the script creates them using fs.ensureDir().

Run During Installation:
    The script is executed automatically as part of the postinstall lifecycle hook in package.json.

Usage

Automatic Page (Zero Configuration)

The package includes a pre-built page component. After installation, you can access it at:

/terminal-port-manager

This page will show a list of common ports (3000, 3001, 3002, 8080) and their status.

Manual Component Usage

import { TerminalPortManager } from 'terminal-port-manager';

function MyComponent() {
  return (
    <TerminalPortManager
      port={3000}
      onPortClear={() => console.log('Port is clear')}
      onPortBusy={(pid) => console.log(`Process ${pid} is using the port`)}
    />
  );
}

Types

interface TerminalPortManagerProps {
  port: number;
  onPortClear?: () => void;
  onPortBusy?: (pid: number) => void;
}

Project Structure

terminal-port-manager/
├── api/
│   └── terminal-port-manager-execute-commands/
│       └── route.ts               # API endpoint for executing commands
├── src/
│   ├── app/
│   │   └── terminal-port-manager/
│   │       └── page.tsx           # Auto-included page component
│   ├── components/
│   │   └── TerminalPortManager.tsx # Main component
│   ├── utils/
│   │   └── portUtils.ts           # Port management utilities
│   └── index.ts                   # Main entry point
├── dist/                          # Built files
│   ├── index.js                   # CommonJS bundle
│   ├── index.mjs                  # ES Modules bundle
│   └── index.d.ts                 # TypeScript declarations
├── package.json
└── tsconfig.json

Requirements

  • Node.js >= 14
  • Next.js >= 13
  • React >= 18

API Reference

TerminalPortManager Component

Props:

  • port (number): The port number to monitor
  • onPortClear (optional function): Callback when port becomes available
  • onPortBusy (optional function): Callback when port is in use, receives process ID

Utility Functions

// Check if a port is in use
async function checkPort(port: number): Promise<number | null>

// Kill a process by its ID
async function killProcess(pid: number): Promise<void>

License

MIT