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

dead-files

v0.1.2

Published

Find unused files in your codebase.

Readme

dead-files

Find unused files in your JavaScript/TypeScript codebase.

Installation

npm install -g dead-files

Or with other package managers:

pnpm add -g dead-files
yarn global add dead-files

Usage

# Scan current directory
dead-files

# Scan a specific directory
dead-files ./src

# Output as JSON (useful for CI/scripting)
dead-files --json

# Include asset files (images, fonts, etc.)
dead-files --include-assets

# Show absolute paths
dead-files --absolute

# Only specific extensions
dead-files -e ts,tsx

# Add custom ignore patterns
dead-files --ignore "**/__mocks__/**,**/fixtures/**"

CLI Options

Usage: dead-files [directory] [options]

Arguments:
  directory              Root directory to scan (default: current directory)

Options:
  -e, --ext <exts>       Comma-separated extensions to include
  --include-assets       Also report unused image/font/svg files
  --json                 Output as JSON
  --absolute             Print absolute paths
  --ignore <patterns>    Additional glob patterns to ignore (comma-separated)
  --no-gitignore         Disable .gitignore respect
  -q, --quiet            Only print file paths, no summary
  -V, --version          Print version
  -h, --help             Print help

Output

Human-readable (default)

dead-files — 3 unused files found in ./src

  • src/components/OldButton.tsx
  • src/utils/deprecated-helper.ts
  • src/styles/legacy.css

  Scanned 142 files in 234ms
  Run with --json for machine-readable output.

JSON mode

{
  "root": "/Users/you/my-project",
  "scanned": 142,
  "unused": [
    "src/components/OldButton.tsx",
    "src/utils/deprecated-helper.ts",
    "src/styles/legacy.css"
  ],
  "durationMs": 234
}

What it detects

dead-files parses all your source files and detects imports in:

  • ESM static imports: import x from "./foo"
  • ESM dynamic imports: import("./lazy-module")
  • CommonJS: require("./something")
  • Re-exports: export { x } from "./module"
  • CSS/SCSS imports: @import "./styles"
  • Jest/Vitest mocks: jest.mock("./module")
  • Webpack require.context: require.context("./icons")
  • Vite glob imports: import.meta.glob("./modules/*")

Entry Point Detection

These files are never marked as unused (they're entry points):

Package exports

  • package.json main, module, bin, and exports fields

Framework pages/routes

  • Next.js: pages/**, app/**/page.tsx, app/**/layout.tsx, etc.
  • Remix: app/routes/**
  • SvelteKit: Uses $lib alias resolution

Config files

  • *.config.js, *.config.ts
  • vite.config.*, next.config.*, tailwind.config.*
  • jest.config.*, vitest.config.*, eslint.config.*
  • .babelrc, babel.config.*

Other entry points

  • src/index.*, src/main.*, src/App.*
  • setupTests.*, vitest.setup.*
  • public/, scripts/
  • Test files (*.test.ts, *.spec.ts, __tests__/**)
  • Storybook stories (*.stories.tsx)

Path Resolution

dead-files understands:

  • Relative imports: ./foo, ../bar/baz
  • TypeScript paths: Reads tsconfig.json paths and baseUrl
  • Common aliases: @/, ~/, #/, $lib/
  • Extensionless imports: Tries .ts, .tsx, .js, etc.
  • Index files: ./components./components/index.ts

Default Ignores

These are always skipped:

node_modules/
.git/
dist/
build/
.next/
.nuxt/
.turbo/
coverage/
*.d.ts
*.min.js
*.map

Adding Custom Ignores

Use --ignore to skip additional patterns:

dead-files --ignore "**/__mocks__/**,**/fixtures/**,**/generated/**"

Or disable .gitignore respect:

dead-files --no-gitignore

CI Integration

dead-files exits with code 1 when unused files are found. Use in CI:

# GitHub Actions
- name: Check for unused files
  run: npx dead-files --json
# GitLab CI
dead-files:
  script:
    - npx dead-files
  allow_failure: false

Performance

  • Handles 10,000+ file codebases efficiently
  • Uses async concurrency for parsing
  • Shows progress spinner for large scans
  • No heavy AST parsing (regex-based extraction)

Requirements

  • Node.js >= 18

License

MIT