dep-peek is a lightweight CLI tool that helps you peek into your project and identify unused dependencies by analyzing real import usage in your source code.
This tool is read-only and safe by design it does not remove or modify any dependencies.
It simply tells you what is actually used vs what is declared.
⚠️ This is v1 of dep-peek. The focus is correctness and clarity over advanced analysis.
In many projects, dependencies get added over time but never removed.
Unused dependencies:
- increase bundle size
- slow down installs
- add maintenance overhead
- create security noise
dep-peek solves this by statically analyzing your source files and comparing real usage against package.json.
- Works with JavaScript & TypeScript
- Supports ESM (
import) and CommonJS (require) - Detects used vs unused dependencies
- Ignores:
- relative imports (
./,../) - Node.js built-in modules (
fs,path, etc.)
- relative imports (
- Handles scoped packages (
@babel/parser) - Safe, non-destructive, read-only CLI
npm install -g dep-peekRun inside your project root:
dep-peek .
Example output:
Used dependencies:
- fast-glob
- @babel/parser
- @babel/traverse
Unused dependencies:
- chalk
- commander`
This tells you exactly which dependencies are declared but never used.
-
Scans your project source files (
.js,.ts,.jsx,.tsx) -
Extracts imports using AST parsing
-
Normalizes and filters valid external packages
-
Compares them with
package.jsondependencies -
Reports used vs unused dependencies
No heuristics. No guesses. Just static analysis.
This version intentionally keeps scope limited:
-
Does not analyze
devDependencies -
Does not remove or modify dependencies
-
Does not handle dynamic imports (
import()with variables) -
No config file support yet
-
Path aliases (@/) are treated as external imports
-
Framework-managed dependencies (e.g. react-dom in Next.js) may appear as unused
-
CLI tools installed as dependencies may appear unused
These are planned improvements.
-
🔜
devDependenciesaudit -
🔜
--jsonstructured output -
🔜 Better reporting & formatting
-
🔜 Performance optimizations for large codebases
-
Developers who want to clean up dependency bloat
-
Teams looking for a safe audit tool
-
CI pipelines that want visibility (future versions)
-
Anyone who prefers clarity over magic
Vaibhav Kumar
-
GitHub: https://github.com/va1bhavx
-
Portfolio: https://kumarvaibhav.xyz