knip vs depcheck vs npm-check
Dependency Audit and Cleanup Tools for JavaScript Projects
knipdepchecknpm-check
Dependency Audit and Cleanup Tools for JavaScript Projects

depcheck, knip, and npm-check are command-line tools designed to help JavaScript developers manage project dependencies by identifying unused, missing, or outdated packages. depcheck analyzes source code to detect dependencies listed in package.json that aren’t actually imported or required. knip provides a more comprehensive audit, checking not only unused dependencies but also missing ones, unused files, and dead exports across the entire codebase. npm-check focuses on interactive dependency management, showing outdated or unused packages and allowing selective updates through a terminal user interface.

Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
knip5,407,1709,9271.61 MB393 days agoISC
depcheck1,395,5314,940231 kB1162 years agoMIT
npm-check298,4256,64594.1 kB233-MIT

Dependency Auditing Tools Compared: depcheck vs knip vs npm-check

When maintaining modern JavaScript projects, keeping dependencies lean and relevant is critical for performance, security, and long-term maintainability. Three popular tools—depcheck, knip, and npm-check—help identify unused or problematic packages, but they differ significantly in scope, architecture, and workflow integration. Let’s examine how each works under real-world conditions.

🔍 Core Functionality: What Each Tool Actually Checks

depcheck focuses exclusively on detecting unused dependencies listed in package.json. It parses your source code (JavaScript, TypeScript, JSX, etc.) and compares required modules against declared dependencies. If a package is in dependencies or devDependencies but never imported or required, it flags it.

# Basic usage
npx depcheck

It does not check for missing dependencies, outdated versions, or interactive updates.

knip takes a broader approach: it identifies unused files, exports, and dependencies, plus missing dependencies and unlisted binaries. It scans your entire codebase—including configuration files—and validates that everything referenced is properly declared.

# Basic usage
npx knip

For example, if you use eslint in a script but forget to list it in devDependencies, knip will catch it.

npm-check emphasizes interactive dependency management: it shows which packages are outdated, unused, or missing, and lets you selectively update or remove them via an interactive TUI.

# Check for issues
npx npm-check

# Interactive update mode
npx npm-check -u

Unlike the others, npm-check provides a visual interface for decision-making, making it beginner-friendly but less suited for CI pipelines.

🧪 Detection Accuracy: False Positives and Edge Cases

All three tools can produce false positives, but their handling differs.

depcheck may miss dynamically required modules (e.g., require(someVar)) or dependencies used only in non-JS files (like Webpack configs). You can configure it with --ignores or custom parsers:

// .depcheckrc
{
  "ignores": ["@types/*", "typescript"]
}

knip reduces false positives by supporting custom entry points and project types. For example, it understands that next uses next.config.js and won’t flag next as unused:

// knip.jsonc
{
  "$schema": "https://unpkg.com/knip@latest/schema.json",
  "entry": ["src/index.ts", "next.config.js"]
}

It also checks for unused TypeScript exports and dead files—features the others lack.

npm-check often flags packages as unused if they’re only used in build scripts or CLI contexts (e.g., prettier called via npm run format). It doesn’t deeply analyze source code structure, relying instead on static string matching of require/import statements.

⚙️ Integration into Developer Workflows

depcheck is designed for automation. Its JSON output integrates cleanly into CI:

# Fail CI if unused deps found
npx depcheck --json | jq -e '.dependencies | length == 0'

No interactive mode exists—it’s purely a linter.

knip supports both CI and local development. It offers machine-readable output (--reporter json) and can auto-fix some issues (e.g., removing unused files):

# Run in CI with strict exit code
npx knip --fail-on-unused

Its plugin system supports frameworks like Next.js, Remix, and Vite out of the box.

npm-check is primarily a local development tool. The interactive update mode (-u) modifies package.json and runs npm install automatically—great for one-off cleanups, but risky in automated environments.

🛑 Maintenance Status and Future Outlook

As of 2024:

  • depcheck is actively maintained, with recent releases addressing ESM and TypeScript parsing.
  • knip is under active, rapid development, frequently adding support for new tooling ecosystems.
  • npm-check has not seen a release since 2021 and shows signs of stagnation. While not officially deprecated, its GitHub repository has unresolved issues and lacks support for modern module systems.

⚠️ Important: npm-check should not be used in new projects due to lack of maintenance and compatibility gaps with current Node.js and npm features.

🆚 Side-by-Side Feature Comparison

Capabilitydepcheckknipnpm-check
Detects unused dependencies
Detects missing dependencies✅ (limited)
Outdated package detection
Interactive update interface
Unused file/export detection
CI/automation friendly
Modern JS/TS support✅ (with config)✅ (built-in)⚠️ (partial)
Active maintenance

💡 Practical Recommendations

  • Use knip if you want a comprehensive, future-proof solution that covers dependencies, dead code, and configuration hygiene. It’s especially valuable in monorepos or complex setups.
  • Use depcheck if you need a lightweight, focused tool just for unused dependencies and already have other systems for version checking.
  • Avoid npm-check in new projects. Its interactive model doesn’t scale, and lack of updates makes it unreliable with modern toolchains.

In short: knip is the most capable and forward-looking; depcheck is a reliable specialist; npm-check is best left in legacy projects.

How to Choose: knip vs depcheck vs npm-check
  • knip:

    Choose knip if you want a holistic solution that not only finds unused dependencies but also detects missing ones, unused files, and dead exports across your entire project—including config files and framework-specific patterns. It’s best for teams seeking deep codebase hygiene with strong support for modern tooling like TypeScript, Next.js, and Vite.

  • depcheck:

    Choose depcheck if you need a lightweight, focused tool that strictly identifies unused dependencies in your package.json based on static code analysis. It’s ideal for CI pipelines where you want deterministic, non-interactive output and already handle version updates and missing dependency checks through other means.

  • npm-check:

    Avoid npm-check in new projects. While it offers an interactive interface for updating or removing dependencies, it hasn’t been actively maintained since 2021 and lacks support for modern JavaScript ecosystems. Use it only for quick audits in legacy projects where interactivity is preferred over accuracy or automation.

README for knip


Knip

NPM Version NPM Downloads GitHub Repo stars

Knip finds and fixes unused dependencies, exports and files in your JavaScript and TypeScript projects. Less code and dependencies lead to improved performance, less maintenance and easier refactorings.

Contributors

Special thanks to the wonderful people who have contributed to Knip!

Knip

/'knɪp/ means "(to) cut" and is pronounced with a hard "K" 🇳🇱

License

Knip is free and open-source software licensed under the ISC License.

Parts of Knip have been inspired by and/or partially copy code from the following projects: