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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dephub/package-manager

v1.0.2

Published

Detect and work with package managers (npm, yarn, pnpm, bun)

Downloads

25

Readme

@dephub/package-manager

Detect and work with package managers (npm, yarn, pnpm, bun) and custom ones

Features ✨

  • 🔍 Detect Available Managers - Find installed package managers on your system
  • 🎯 Priority Detection - Specify preferred package manager order
  • 🚀 Zero Dependencies - Only uses @dephub/spawn for child processes
  • 🔒 Type Safe - Full TypeScript support with strict types
  • 🔧 Extensible - Support for custom package managers
  • 💻 CLI & API - Use via command line or programmatically

Installation 💿

# Using npm
npm install @dephub/package-manager

# Using pnpm
pnpm add @dephub/package-manager

# Using yarn
yarn add @dephub/package-manager

# Using bun
bun add @dephub/package-manager

CLI Usage 🖥️

Basic Commands

# Detect available package managers
package-manager detect

# Get first available package manager
package-manager first

# Detect local package manager from lock files
package-manager local

# Detect workspace package manager (monorepo support)
package-manager workspace

# Detect globally installed package managers
package-manager global

Options

Global Options (apply to all commands)

  • --cwd <path> - Working directory for detection
  • --additional <managers> - Additional package managers to check (comma-separated)

Command-specific Flags

  • detect command:
    • --required - Throw error if no package manager is found

Examples

# Detect in specific directory
package-manager detect --cwd /path/to/project

# Detect with required flag
package-manager detect --required

# Detect with additional package managers
package-manager global --additional deno,flutter

# Combine global options with commands
package-manager detect --cwd /path/to/project --additional deno

Programmatic Usage 🛠️

import { packageManager } from '@dephub/package-manager';

// Detect all available package managers
const managers = await packageManager.detect();
console.log(managers); // ['pnpm', 'npm']

// Get first available package manager
const manager = await packageManager.detectFirst();
console.log(manager); // 'pnpm'

// Detect local package manager
const localManager = await packageManager.detectLocal();
console.log(localManager); // 'pnpm' or null

// Detect workspace package manager
const workspaceManager = await packageManager.detectWorkspace();
console.log(workspaceManager); // 'pnpm' or null

// Detect global package managers
const globalManagers = await packageManager.detectGlobal();
console.log(globalManagers); // ['npm', 'pnpm', 'yarn']

// Detect with custom package managers
const customManagers = await packageManager.detectGlobal({
  additionalManagers: ['flutter', 'deno'],
});
console.log(customManagers); // ['npm', 'pnpm', 'flutter'] if flutter is installed

API Reference 📚

packageManager.detect(options?)

Detect all available package managers.

Parameters:

  • options (DetectionOptions) - Optional configuration
    • priority - Array of package managers to check first
    • additionalManagers - Additional custom package managers to check
    • required - Throw if no package manager is found (default: true)
    • scope - Detection scope: 'local', 'workspace', 'global', or 'auto' (default: 'auto')
    • cwd - Working directory for detection (default: process.cwd())

Returns: Promise<PackageManager[]> - Array of detected package managers

packageManager.detectFirst(options?)

Detect first available package manager.

Parameters:

  • options (DetectionOptions) - Optional configuration

Returns: Promise<PackageManager | null>

packageManager.detectLocal(cwd?)

Detect package manager in the current directory using lock files.

Parameters:

  • cwd (string) - Current working directory (default: process.cwd())

Returns: Promise<PackageManager | null>

packageManager.detectWorkspace(cwd?)

Detect package manager by traversing up the directory tree.

Parameters:

  • cwd (string) - Starting directory (default: process.cwd())

Returns: Promise<PackageManager | null>

packageManager.detectGlobal(options?)

Detect globally installed package managers.

Parameters:

  • options (DetectionOptions) - Optional configuration

Returns: Promise<PackageManager[]>

Detection Scopes 🔎

  • local: Only check the current directory for lock files
  • workspace: Check current and parent directories for lock files (monorepo support)
  • global: Check globally installed package managers
  • auto: Try local, then workspace, then global (default)

Types

PackageManager

type KnownPackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';
type PackageManager = KnownPackageManager | string;

DetectionOptions

interface DetectionOptions {
  priority?: PackageManager[];
  additionalManagers?: PackageManager[];
  required?: boolean;
  scope?: 'local' | 'workspace' | 'global' | 'auto';
  cwd?: string;
}

License 📄

MIT License

Author: Estarlin R (estarlincito.com)


Note: This package is part of the DepHub ecosystem - a collection of focused, modular tools for modern JavaScript development.