Key Features • Installation • Practical Examples • CLI Reference
Dependency analysis and optimization toolkit for modern JavaScript and TypeScript projects.
Trace imports, find unused code, clean dependencies — all from a blazing-fast CLI.
Working in large JS/TS projects makes it difficult to answer simple but crucial questions:
- Which files depend on this file?
- Is this file even used?
- Which files does this entry point import?
- Do I have circular dependencies?
- Which packages in node_modules are unused?
- Which modules take the most disk space?
Rev-dep helps you understand the real structure of your codebase so you can debug issues faster, refactor safely, and keep your dependencies clean.
It's particularly useful for JavaScript projects without TypeScript or test coverage — places where answering question "What will break if I change this" is not straightforward
Rev-dep is designed for fast iteration and minimal, actionable results — no noise, just answers.
Built in Go for speed. Even on large codebases, rev-dep responds almost instantly.
You get exact file paths, import chains, and clear dependency relationships — the kind of information you can fix or clean up right away.
Works with mixed JS/TS projects, path aliases and thousands of files without configuration hassles.
Unused files, unused or missing dependencies, reverse-imports, entry point detection, node_modules insights, dependency paths — everything in one tool.
Rev-dep outperforms Madge, dpdm, dependency-cruiser, skott, knip, depcheck and other similar tools.
For large project with 500k+ lines of code and 6k+ source code files get checks as fast as:
| Task | Execution Time [ms] | Alternative | Alternative Time [ms] | Slower Than Rev-dep |
|---|---|---|---|---|
| Find circular dependencies | 289 | dpdm-fast | 7061 | 24x |
| Find unused files | 588 | knip | 6346 | 11x |
| Find unused node modules | 594 | knip | 6230 | 10x |
| Find missing node modules | 553 | knip | 6226 | 11x |
| List all files imported by an entry point | 229 | madge | 4467 | 20x |
| Discover entry points | 323 | madge | 67000 | 207x |
| Resolve dependency path between files | 228 | please suggest | ||
| Count lines of code | 342 | please suggest | ||
| Check node_modules disk usage | 1619 | please suggest | ||
| Analyze node_modules directory sizes | 521 | please suggest |
Benchmark run on WSL Linux Debian Intel(R) Core(TM) i9-14900KF CPU @ 2.80GHz
- 🔍 Reverse dependency lookup — see all entry points that require a given file
- 🗂️ Entry point discovery
- 🧹 Dead file detection
- 📦 Unused / missing / used node modules / dependencies analysis
- 🔄 Circular imports/dependencies detection
- 🧭 Trace all import paths between files
- 📁 List all files imported by any entry point
- 📏 Count actual lines of code (excluding comments and blanks)
- 💽 Node modules disk usage & size analysis
- 💡 Works with both JavaScript and TypeScript
- ⚡ Built for large codebases
Install globally to use as a CLI tool:
yarn global add rev-dep
npm install -g rev-dep
pnpm global add rev-dep
A few instant-use examples to get a feel for the tool:
# Detect unused node modules
rev-dep node-modules unused
# Detect circular imports/dependencies
rev-dep circular
# List all entry points in the project
rev-dep entry-points
# Check which files an entry point imports
rev-dep files --entry-point src/index.ts
# Find every entry point that depends on a file
rev-dep resolve --file src/utils/math.ts
# Resolve dependency path between files
rev-dep resolve --file src/utils/math.ts --entry-point src/index.ts
Practical examples show how to use rev-dep commands to build code quality checks for your project.
rev-dep resolve --file path/to/file.ts
You’ll see all entry points that implicitly require that file, along with resolution paths.
rev-dep resolve --file path/to/file.ts --compact-summary
Shows how many entry points indirectly depend on the file.
rev-dep entry-points
Exclude framework entry points if needed using --result-exclude.
rev-dep files --entry-point path/to/file.ts
Useful for identifying heavy components or unintended dependencies.
-
List all files imported:
rev-dep files --entry-point path/to/entry.ts -
Identify suspicious files.
-
Trace why they are included:
rev-dep resolve --file path/to/suspect --entry-points path/to/entry.ts --all
rev-dep circular
rev-dep node-modules unused
rev-dep node-modules missing
rev-dep node-modules dirs-size
Rev-dep@2.0.0 was reimplemented in Go from scratch to leverage it's concurrency features and better memory management of compiled languages.
As a result v2 is up to 37x faster than v1 and consumes up to 13x less memory.
To compare performance rev-dep was benchmarked with hyperfine using 8 runs per test, taking mean time values as a result. Benchmark was run on TypeScript codebase with 507658 lines of code and 5977 source code files.
Memory usage on Mac was measure using /usr/bin/time utility. Memory usage on Linux was not measured because I could't find reliable way to measure RAM usage on Linux. Subsequent runs had too much fluctuation.
| Command | V1 Time | V2 Time | Time Change | V1 RAM | V2 RAM | RAM Change |
|---|---|---|---|---|---|---|
List entry-points rev-dep entry-points |
6500ms | 347ms | 19x | ~680MB | ~51MB | 13x |
List entry-points with dependent files count -pdc |
8333ms | 782ms | 11x | ~885MB | ~110MB | 8x |
List entry-point files rev-dep files |
2729ms | 400ms | 7x | ~330MB | ~36MB | 9x |
Resolve dependency path rev-dep resolve |
2984ms | 359ms | 8x | ~330MB | ~35MB | 9x |
| Command | V1 Time | V2 Time | Time Change |
|---|---|---|---|
List entry-points rev-dep entry-points |
9904ms | 270ms | 37x |
List entry-points with dependent files count --print-deps-count |
10562ms | 458ms | 23x |
List entry-point files rev-dep files |
3097ms | 230ms | 13x |
Resolve dependency path rev-dep resolve |
3146ms | 230ms | 14x |
V2 comes with bunch of new commands
circular- detects circular dependencies in the projectlines-of-code- counts actual lines of code in the project excluding comments and blank lineslist-cwd-files- lists all files in the current working directorynode-modules used- lists all used node modulesnode-modules unused- lists all unused node modulesnode-modules missing- lists all missing node modulesnode-modules installed- lists all installed node modulesnode-modules installed-duplicates- lists all installed node modules that exist in file system with the same version multiple timesnode-modules analyze-size- analyzes size of specific node modules and helps to identify space-hogging dependenciesnode-modules dirs-size- calculates cumulative files size in node_modules directories
Comparing to previous versions, these tsconfig features are not supported
If you tsconfig uses extends, and you have some paths defined in config being extended, paths from extended config won't be used during resolution
eg.
// tsconfig.json
{
"extends": "./tsconfig.base.json",
"paths": {
"@/components": ["src/components/*"]
}
}// tsconfig.base.json
{
"paths": {
"@/utils": ["src/utils/*"]
}
}In that scenario imports with @/utils won't be resolved.
Why it's not supported ? I consider this typescript capability as an usage edge-case. I forgot to to implement it at the begging and I don't feel like investing more time now, before this package get some reasonable adoption and people will be actually requesting this feature.
Only first path will be used in resolution.
// tsconfig.json
{
"paths": {
"@/components": ["src/components/*", "src/components2/*"]
}
}Imports that should resolve to src/components2/* will be considered unresolved.
Why it's not supported? I consider this typescript capability as an anti-pattern. It introduces unnecessary ambiguity in module resolution. Implementing this would make code more complex, less maintainable and slower.
Importing rev-dep in JS/TS is no longer supported. Preferred way is to run rev-dep using child process.
Any other discrepancies between TypeScript module resolution and rev-dep should be considered as a bug.
- Linux x64
- MacOS Apple Silicon
- Windows x64
Go allows for cross-compiling, so I'm happy to build and distribute binaries for other platforms as well. Feel free to open an issue if you need support for another platform.
Detect circular dependencies in your project
Analyzes the project to find circular dependencies between modules. Circular dependencies can cause hard-to-debug issues and should generally be avoided.
rev-dep circular [flags]
rev-dep circular --ignore-types-imports
-c, --cwd string Working directory for the command (default "$PWD")
-h, --help help for circular
-t, --ignore-type-imports Exclude type imports from the analysis
--package-json string Path to package.json (default: ./package.json)
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
Discover and list all entry points in the project
Analyzes the project structure to identify all potential entry points. Useful for understanding your application's architecture and dependencies.
rev-dep entry-points [flags]
rev-dep entry-points --print-deps-count
-n, --count Only display the number of entry points found
-c, --cwd string Working directory for the command (default "$PWD")
--graph-exclude strings Exclude files matching these glob patterns from analysis
-h, --help help for entry-points
-t, --ignore-type-imports Exclude type imports from the analysis
--package-json string Path to package.json (default: ./package.json)
--print-deps-count Show the number of dependencies for each entry point
--result-exclude strings Exclude files matching these glob patterns from results
--result-include strings Only include files matching these glob patterns in results
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
List all files in the dependency tree of an entry point
Recursively finds and lists all files that are required by the specified entry point.
rev-dep files [flags]
rev-dep files --entry-point src/index.ts
-n, --count Only display the count of files in the dependency tree
-c, --cwd string Working directory for the command (default "$PWD")
-p, --entry-point string Entry point file to analyze (required)
-h, --help help for files
-t, --ignore-type-imports Exclude type imports from the analysis
--package-json string Path to package.json (default: ./package.json)
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
Count actual lines of code in the project excluding comments and blank lines
rev-dep lines-of-code [flags]
rev-dep lines-of-code
-c, --cwd string Directory to analyze (default "$PWD")
-h, --help help for lines-of-code
List all files in the current working directory
Recursively lists all files in the specified directory, with options to filter results.
rev-dep list-cwd-files [flags]
rev-dep list-cwd-files --include='*.ts' --exclude='*.test.ts'
--count Only display the count of matching files
--cwd string Directory to list files from (default "$PWD")
--exclude strings Exclude files matching these glob patterns
-h, --help help for list-cwd-files
--include strings Only include files matching these glob patterns
Analyze and manage Node.js dependencies
Tools for analyzing and managing Node.js module dependencies. Helps identify unused, missing, or duplicate dependencies in your project.
rev-dep node-modules used -p src/index.ts
rev-dep node-modules unused --exclude-modules=@types/*
rev-dep node-modules missing --entry-points=src/main.ts
-h, --help help for node-modules
Calculates cumulative files size in node_modules directories
Calculates and displays the size of node_modules folders in the current directory and subdirectories. Sizes will be smaller than actual file size taken on disk. Tool is calculating actual file size rather than file size on disk (related to disk blocks usage)
rev-dep node-modules dirs-size [flags]
rev-dep node-modules dirs-size
-c, --cwd string Working directory for the command (default "$PWD")
-h, --help help for dirs-size
Find and optimize duplicate package installations
Identifies packages that are installed multiple times in node_modules. Can optimize storage by creating symlinks between duplicate packages.
rev-dep node-modules installed-duplicates [flags]
rev-dep node-modules installed-duplicates --optimize --size-stats
-c, --cwd string Working directory for the command (default "$PWD")
-h, --help help for installed-duplicates
--isolate Create symlinks only within the same top-level node_module directories. By default optimize creates symlinks between top-level node_module directories (eg. when workspaces are used). Needs --optimize flag to take effect
--optimize Automatically create symlinks to deduplicate packages
--size-stats Print node modules dirs size before and after optimization. Might take longer than optimization itself
--verbose Show detailed information about each optimization
List all installed npm packages in the project
Recursively scans node_modules directories to list all installed packages. Helpful for auditing dependencies across monorepos.
rev-dep node-modules installed [flags]
rev-dep node-modules installed --include-modules=@myorg/*
-c, --cwd string Working directory for the command (default "$PWD")
-e, --exclude-modules strings list of modules to exclude from the output
-h, --help help for installed
-i, --include-modules strings list of modules to include in the output
Find imported packages not listed in package.json
Identifies packages that are imported in your code but not declared in your package.json dependencies.
rev-dep node-modules missing [flags]
rev-dep node-modules missing --entry-points=src/main.ts
-n, --count Only display the count of modules
-c, --cwd string Working directory for the command (default "$PWD")
-p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
-e, --exclude-modules strings list of modules to exclude from the output
-b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
-m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
--group-by-file Organize output by project file path
--group-by-module Organize output by npm package name
-h, --help help for missing
-t, --ignore-type-imports Exclude type imports from the analysis
-i, --include-modules strings list of modules to include in the output
--package-json string Path to package.json (default: ./package.json)
--pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
--zero-exit-code Use this flag to always return zero exit code
Find installed packages that aren't imported in your code
Compares package.json dependencies with actual imports in your codebase to identify potentially unused packages.
rev-dep node-modules unused [flags]
rev-dep node-modules unused --exclude-modules=@types/*
-n, --count Only display the count of modules
-c, --cwd string Working directory for the command (default "$PWD")
-p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
-e, --exclude-modules strings list of modules to exclude from the output
-b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
-m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
-h, --help help for unused
-t, --ignore-type-imports Exclude type imports from the analysis
-i, --include-modules strings list of modules to include in the output
--package-json string Path to package.json (default: ./package.json)
--pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
--zero-exit-code Use this flag to always return zero exit code
List all npm packages imported in your code
Analyzes your code to identify which npm packages are actually being used. Helps keep track of your project's runtime dependencies.
rev-dep node-modules used [flags]
rev-dep node-modules used -p src/index.ts --group-by-module
-n, --count Only display the count of modules
-c, --cwd string Working directory for the command (default "$PWD")
-p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
-e, --exclude-modules strings list of modules to exclude from the output
-b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
-m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
--group-by-file Organize output by project file path
--group-by-module Organize output by npm package name
-h, --help help for used
-t, --ignore-type-imports Exclude type imports from the analysis
-i, --include-modules strings list of modules to include in the output
--package-json string Path to package.json (default: ./package.json)
--pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
Trace and display the dependency path between files in your project
Analyze and display the dependency chain between specified files. Helps understand how different parts of your codebase are connected.
rev-dep resolve [flags]
rev-dep resolve -p src/index.ts -f src/utils/helpers.ts
-a, --all Show all possible resolution paths, not just the first one
--compact-summary Display a compact summary of found paths
-c, --cwd string Working directory for the command (default "$PWD")
-p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
-f, --file string Target file to check for dependencies
--graph-exclude strings Glob patterns to exclude files from dependency analysis
-h, --help help for resolve
-t, --ignore-type-imports Exclude type imports from the analysis
--package-json string Path to package.json (default: ./package.json)
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
Benchmark performed on TypeScript codebase with 6034 source code files and 518862 lines of code.
Benchmark performed on MacBook Pro with Apple M1 chip, 16GB of RAM and 256GB of Storage. Power save mode off.
Benchmark performed with hyperfine using 8 runs per test and 4 warm up runs, taking mean time values as a result. If single run was taking more than 10s, only 1 run was performed.
rev-dep circular check is 12 times faster than the fastest alternative❗
| Tool | Version | Command to Run Circular Check | Time |
|---|---|---|---|
| 🥇 rev-dep | 2.0.0 | rev-dep circular |
397 ms |
| 🥈 dpdm-fast | 1.0.14 | dpdm --no-tree --no-progress --no-warning + list of directories with source code |
4960 ms |
| 🥉 dpdm | 3.14.0 | dpdm --no-warning + list of directories with source code |
5030 ms |
| skott | 0.35.6 | node skoscript using findCircularDependencies function |
29575 ms |
| madge | 8.0.0 | madge --circular --extensions js,ts,jsx,tsx . |
69328 ms |
| circular-dependency-scanner | 2.3.0 | ds - out of memory error |
n/a |
Some of the terms used in the problem space that rev-dep covers can be confusing. Here is a small glossary to help you navigate the concepts.
A dependency can be understood literally. In the context of a project’s dependency graph, it may refer to:
- a node module / package (a package is a dependency of a project or file), or
- a source code file (a file is a dependency of another file if it imports it).
An entry point is a source file that is not imported by any other file. It can represent:
- the main entry of the application
- an individual page or feature
- configuration or test bootstrap files
— depending on the project structure.
A file is considered unused or dead when:
- it is an entry point (nothing imports it), and
- running it does not produce any meaningful output or side effect.
In practice, such files can often be removed safely.
A circular dependency occurs when a file directly or indirectly imports itself through a chain of imports.
This can lead to unpredictable runtime behavior, uninitialized values, or subtle bugs. However, circular dependencies between TypeScript type-only imports are usually harmless.
Files that import a given file. Useful for answering: "What breaks if I change or delete this file?"
A visual representation of how files or modules import each other.
A module that your code imports but is not listed in package.json.
A dependency listed in package.json that is never imported in the source code.
The top-level directory used as the starting point for dependency analysis.
Made in 🇵🇱 and 🇯🇵 with 🧠 by @jayu
I hope that this small piece of software will help you discover and understood complexity of your project hence make you more confident while refactoring. If this tool was useful, don't hesitate to give it a ⭐!