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

dep-why

v0.0.1

Published

Understand why you have multiple versions of a package - human-friendly dependency analysis

Readme

dep-why

Understand why you have multiple versions of a package - human-friendly dependency analysis

npm version License: MIT

Problem

"Why do I have 3 versions of React in node_modules?"

npm why output is confusing. npm ls is overwhelming. You just want to know why and how to fix it.

Solution

dep-why shows you exactly why you have multiple versions with clear dependency chains and actionable suggestions.

Features

  • Human-readable output - Clear dependency chains, not nested JSON
  • Grouped by version - See all paths to each version at once
  • Actionable suggestions - Dedupe, update, or override recommendations
  • Find all duplicates - Scan entire project with --all
  • Color-coded - Newest version green, oldest red
  • Works everywhere - npm, yarn, pnpm projects

Installation

# Run directly with npx (recommended)
npx dep-why react

# Or install globally
npm install -g dep-why

Usage

Analyze a Specific Package

# Why do I have multiple versions of lodash?
npx dep-why lodash

# Analyze in a different directory
npx dep-why react --path ./my-project

# Output as JSON
npx dep-why lodash --json

Find All Duplicates

# List all packages with multiple versions
npx dep-why --all

# Or just run without arguments
npx dep-why

Example Output

📦 Why you have 3 versions of react:

[email protected] (1 instance)
  └─ (direct dependency in package.json)

[email protected] (2 instances)
  ├─ [email protected]
  └─ [email protected]

[email protected] (1 instance)
  └─ [email protected]

💡 Suggestions:

🔥 Run npm dedupe to reduce duplicates
   npm dedupe attempts to simplify the dependency tree by moving packages up

⚡ Update react-datepicker to a newer version
   [email protected] requires [email protected]. A newer version may support [email protected]

⚡ Update legacy-component to a newer version
   [email protected] requires [email protected]. A newer version may support [email protected]

💭 Use npm overrides to force a single version
   Add to package.json:
   "overrides": {
     "react": "18.2.0"
   }

──────────────────────────────────────────────────
Solved dependency hell? Consider supporting:
☕ https://buymeacoffee.com/willzhangfly

Find All Duplicates

$ npx dep-why --all

📦 Found 5 packages with multiple versions:

  • react
  • lodash
  • tslib
  • semver
  • debug

Run `dep-why <package-name>` to see details for a specific package.

Comparison with Alternatives

| Feature | dep-why | npm why | npm ls | yarn why | |---------|---------|---------|--------|----------| | Human-readable | ✅ | ❌ | ❌ | ⚠️ | | Grouped by version | ✅ | ❌ | ❌ | ❌ | | Actionable suggestions | ✅ | ❌ | ❌ | ❌ | | Find all duplicates | ✅ | ❌ | ⚠️ | ❌ | | Color-coded output | ✅ | ❌ | ❌ | ⚠️ | | Works with any PM | ✅ | npm only | npm only | yarn only | | No install needed | ✅ (npx) | ✅ | ✅ | ✅ |

Why Not npm why?

# npm why output (confusing)
$ npm why react
[email protected]
node_modules/react-datepicker/node_modules/react
  react@"^17.0.0" from [email protected]
  node_modules/react-datepicker
    react-datepicker@"^4.8.0" from the root project

# dep-why output (clear)
$ npx dep-why react
📦 Why you have 2 versions of react:

[email protected] (1 instance)
  └─ (direct dependency in package.json)

[email protected] (1 instance)
  └─ [email protected]

💡 Suggestions:
🔥 Run npm dedupe to reduce duplicates
⚡ Update react-datepicker to a newer version

CLI Options

Usage: dep-why [options] [package]

Arguments:
  package              Package name to analyze

Options:
  -p, --path <dir>     Project directory (default: current directory)
  --json               Output results as JSON
  --all                Show all packages with duplicates
  -V, --version        Output version number
  -h, --help           Display help

Programmatic Usage

import { analyzePackage, findDuplicates } from 'dep-why';

// Analyze a specific package
const result = analyzePackage('react', '/path/to/project');
console.log(result.versions);
console.log(result.suggestions);

// Find all duplicates
const duplicates = findDuplicates('/path/to/project');
console.log(duplicates); // ['react', 'lodash', ...]

How It Works

  1. Runs npm ls --json to get the full dependency tree
  2. Finds all instances of the target package
  3. Groups by version and traces dependency chains
  4. Generates actionable suggestions based on patterns

Common Solutions

1. npm dedupe

npm dedupe

Attempts to reduce duplication by moving packages up the tree.

2. Update Dependencies

Check if parent packages have newer versions that support your desired version:

npm outdated
npm update <package-name>

3. Use npm overrides (npm 8.3+)

Force a specific version across all dependencies:

{
  "overrides": {
    "react": "18.2.0"
  }
}

4. Use yarn resolutions

{
  "resolutions": {
    "react": "18.2.0"
  }
}

Requirements

  • Node.js 18.0.0 or higher
  • npm, yarn, or pnpm project with node_modules

Support

This project is maintained in my free time. If it helped you escape dependency hell, I'd really appreciate your support:

Thank you to everyone who has contributed, shared feedback, or helped spread the word!

License

MIT


Made with ❤️ for cleaner node_modules