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

@dephub/package-check

v1.0.3

Published

Check if packages are installed locally, in workspace, or globally

Readme

@dephub/package-check

Check if packages are installed locally, in workspace, or globally

NPM version ESM-only

Features ✨

  • 🔍 Multi-scope Checking - Check packages in local, workspace, or global scope
  • 🎯 Smart Resolution - Uses Node.js resolution for comprehensive package detection
  • 🚀 Zero Dependencies - Only uses @dephub packages for core functionality
  • 🔒 Type Safe - Full TypeScript support with strict types
  • 💻 CLI & API - Use via command line or programmatically

Installation 💿

# Using npm
npm install @dephub/package-check

# Using pnpm
pnpm add @dephub/package-check

# Using yarn
yarn add @dephub/package-check

# Using bun
bun add @dephub/package-check

CLI Usage 🖥️

Basic Commands

# Check if a package is installed (auto scope)
package-check check eslint

# Check locally installed package
package-check local typescript

# Check workspace package (monorepo support)
package-check workspace react

# Check globally installed package
package-check global npm

Options

  • --cwd <path> - Working directory for checking
  • --scope <scope> - Check scope: local, workspace, global, auto
  • --rootOnly - Check only the root package (not nested dependencies)
  • --globalPaths <paths> - Additional global paths to check

Examples

# Check with specific directory
package-check check eslint --cwd /path/to/project

# Check only root-level dependencies
package-check check typescript --rootOnly

# Check in workspace scope
package-check check react --scope workspace

# Check with custom global paths
package-check global npm --globalPaths "/usr/lib/node_modules,/custom/path"

Programmatic Usage 🛠️

import { packageChecker } from '@dephub/package-check';

// Check if package is installed (auto scope)
const isInstalled = await packageChecker.check('eslint');
console.log(isInstalled); // true or false

// Check specific scope
const isLocal = await packageChecker.checkLocal('typescript');
const isWorkspace = await packageChecker.checkWorkspace('react');
const isGlobal = await packageChecker.checkGlobal('npm');

// Check with options
const isAvailable = await packageChecker.check('eslint', {
  scope: 'workspace',
  cwd: '/path/to/project',
  rootOnly: true,
});

API Reference 📚

packageChecker.check(pkg, options?)

Check if a package is installed in the specified scope.

Parameters:

  • pkg (string) - Package name to check
  • options (CheckOptions) - Optional configuration
    • scope - Check scope: 'local', 'workspace', 'global', or 'auto' (default: 'auto')
    • cwd - Working directory for checking (default: process.cwd())
    • rootOnly - Enforce package must be in root-level node_modules (default: false)
    • globalPaths - Additional global paths to check

Returns: Promise<boolean> - True if package is installed

packageChecker.checkLocal(pkg, options?)

Check if a package is installed locally.

Parameters:

  • pkg (string) - Package name to check
  • options (object) - Optional configuration
    • cwd - Working directory (default: process.cwd())
    • rootOnly - Check only root-level package (default: false)

Returns: Promise<boolean>

packageChecker.checkWorkspace(pkg, options?)

Check if a package is installed in workspace.

Parameters:

  • pkg (string) - Package name to check
  • options (CheckOptions) - Optional configuration

Returns: Promise<boolean>

packageChecker.checkGlobal(pkg, options?)

Check if a package is installed globally.

Parameters:

  • pkg (string) - Package name to check
  • options (object) - Optional configuration
    • globalPaths - Additional global paths to check

Returns: Promise<boolean>

Check Scopes 🔎

  • local: Check in current directory using Node.js resolution
  • workspace: Check in current and parent directories (monorepo support)
  • global: Check in global package manager directories
  • auto: Check local → workspace → global (default)

Root-Only Mode 🎯

When rootOnly: true is enabled:

  • Only checks direct dependencies in node_modules/package-name
  • Ignores nested dependencies and pnpm store (.pnpm directory)
  • Useful for verifying direct project dependencies

When rootOnly: false (default):

  • Uses Node.js require.resolve for comprehensive detection
  • Finds packages anywhere in node_modules hierarchy
  • Works with all package managers (npm, yarn, pnpm, bun)

Examples 💡

Basic Checking

// Quick check in auto scope
const hasEslint = await packageChecker.check('eslint');

// Scope-specific checks
const hasLocal = await packageChecker.checkLocal('typescript');
const hasWorkspace = await packageChecker.checkWorkspace('react');
const hasGlobal = await packageChecker.checkGlobal('npm');

Advanced Usage

// Check only direct dependencies
const isDirectDep = await packageChecker.checkLocal('eslint', {
  rootOnly: true,
});

// Check in specific directory structure
const hasPackage = await packageChecker.check('vue', {
  scope: 'workspace',
  cwd: '/path/to/monorepo',
});

// Check with custom global paths
const hasGlobalPkg = await packageChecker.checkGlobal('custom-pm', {
  globalPaths: ['/custom/global/path'],
});

Integration in Tools

// Verify required tools are available
const requiredTools = ['typescript', 'eslint', 'prettier'];
for (const tool of requiredTools) {
  if (!(await packageChecker.check(tool))) {
    throw new Error(`Required tool ${tool} is not installed`);
  }
}

Types

CheckScope

type CheckScope = 'local' | 'workspace' | 'global' | 'auto';

CheckOptions

interface CheckOptions {
  globalPaths?: string[];
  scope?: CheckScope;
  cwd?: string;
  rootOnly?: boolean;
}

License 📄

MIT License

Author: Estarlin R (estarlincito.com)