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

@superxepic/nodewhy

v1.0.0

Published

πŸ” Why is this package in your node_modules? nodewhy tells you exactly who dragged it in and how deep.

Readme

nodewhy

πŸ” Why is this package in your node_modules?
Trace exactly who dragged it in β€” and how deep.

A CLI tool & Node.js library by superxepic.


Install

npm install -g nodewhy
# or use without installing:
npx nodewhy <package>

Usage

nodewhy <package-name> [options]

Examples

# Who pulled in lodash?
nodewhy lodash

# Check a specific project
nodewhy axios --cwd /path/to/project

# Output as JSON (great for scripts)
nodewhy typescript --json

# Ignore devDependencies from your root
nodewhy eslint --no-dev

Sample Output

nodewhy Β· lodash
────────────────────────────────────────────────

  β—† Pulled in transitively via 1 path:

    my-app (your project)
    β”œβ”€β”€ [email protected] [dep]
       └── [email protected] [dep]
          └─▢ [email protected] [dep]

  depth: 3 Β· paths found: 1

Options

| Flag | Description | | ----------------- | ------------------------------------------- | | --json | Output result as JSON | | --all | Show all transitive paths (default: max 10) | | --cwd <dir> | Set project root (default: process.cwd()) | | --no-dev | Exclude devDependencies from root package | | --help, -h | Show help | | --version, -v | Show version |


Dependency Type Legend

| Badge | Meaning | | -------- | ---------------------- | | [dep] | dependencies | | [dev] | devDependencies | | [peer] | peerDependencies | | [opt] | optionalDependencies |


Programmatic API

import { findWhy, formatResult } from "nodewhy";

const result = await findWhy("lodash", {
  projectRoot: "/path/to/project",
  includeDevDeps: true,
});

console.log(formatResult(result, "my-app"));

// Or access the raw data:
console.log(result.found); // boolean
console.log(result.paths); // TraceStep[][]

findWhy(packageName, options)

| Param | Type | Description | | ------------------------ | --------- | ------------------------------------------- | | packageName | string | The package to search for | | options.projectRoot | string | Path to the project root | | options.includeDevDeps | boolean | Include devDeps from root (default: true) |

Returns a TraceResult:

interface TraceResult {
  target: string; // package you searched for
  found: boolean; // whether it exists in node_modules
  paths: TraceStep[][]; // all dependency chains leading to it
}

interface TraceStep {
  package: string;
  version: string;
  dependencyType:
    | "dependencies"
    | "devDependencies"
    | "peerDependencies"
    | "optionalDependencies";
}

How it works

nodewhy performs a breadth-first search through your project's node_modules, reading each package's package.json to build a dependency graph. It then finds every path from your project root to the target package β€” including all transitive chains β€” and presents them ranked by depth.

No npm ls subprocess. No internet. Pure filesystem traversal.


License

MIT Β© superxepic