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

dependency-usage-analyzer

v1.0.1

Published

Analyze Node.js project dependencies to find unused, undeclared, and risky packages.

Readme

Dependency Usage Analyzer (DUA)

A production-ready CLI tool to analyze Node.js project dependencies. It detects unused, undeclared, and risky packages to help you optimize your project's security and performance.

Features

  • Unused Dependency Detection: Finds packages listed in package.json but never imported in your code.
  • Undeclared Dependency Detection: Finds packages imported in your code but missing from package.json.
  • Risk Assessment: Checks for deprecated packages and assigns a basic risk score.
  • Size Analysis: Calculates the disk size of each dependency in node_modules.
  • Support for JS/TS: Works with JavaScript, TypeScript, JSX, and TSX files.

How It Helps

  • Reduce Bundle Size: Identify and remove unused dependencies to make your application lighter and faster.
  • Improve Security: Detect deprecated or risky packages that might introduce vulnerabilities.
  • Clean Up Codebase: Find undeclared dependencies that might break your build in different environments.
  • Save Time: Automate the manual process of checking imports vs package.json.

Installation

You can install it globally or run it directly with npx.

# Install globally
npm install -g dependency-usage-analyzer

# OR run directly with npx (Recommended)
npx dependency-usage-analyzer

Step-by-Step Guide

  1. Open your terminal and navigate to the root directory of your Node.js project (where your package.json is located).

    cd /path/to/your/project
  2. Run the analyzer. You can simply run:

    npx dependency-usage-analyzer
  3. View the Report. The tool will scan your files and output a table showing:

    • Which packages are used vs unused.
    • The size of each package on disk.
    • Deprecation warnings or risk status.
  4. Take Action:

    • Uninstall unused packages: npm uninstall <package-name>
    • Install undeclared packages: npm install <package-name>
    • Replace deprecated packages: Look for modern alternatives.

Advanced Usage

  • Output as JSON (for CI/CD pipelines):
    npx dependency-usage-analyzer --json
  • Fail on Unused (strict mode for CI):
    npx dependency-usage-analyzer --fail-on-unused
  • Skip Metadata Fetching (offline mode or faster run):
    npx dependency-usage-analyzer --no-enrich

Example Output

Starting dependency analysis...
Fetching package metadata...
Calculating package sizes...
┌──────────────────────┬──────┬──────┬──────────┬──────────┐
│ Package              │ Type │ Used │ Size     │ Status   │
├──────────────────────┼──────┼──────┼──────────┼──────────┤
│ react                │ Prod │ Yes  │ 2.5 MB   │ OK       │
│ lodash               │ Prod │ No   │ 4.1 MB   │ Unused   │
│ request              │ Prod │ Yes  │ 1.2 MB   │ Deprecated │
└──────────────────────┴──────┴──────┴──────────┴──────────┘

Summary:
Total Dependencies: 3
Unused: 1
Undeclared: 0

Development

  1. Clone the repository.
  2. Install dependencies: npm install
  3. Build the project: npm run build
  4. Run the CLI locally: node bin/dua.js

Author & Connect

Built by Devesh Kumar Thakur

Connect with me:

If you find this SDK helpful, feel free to ⭐ star the repository and connect!

License

ISC