🔥 Explore this trending post from Hacker News 📖
📂 **Category**:
📌 **What You’ll Learn**:
Capabilities •
Installation •
Exploratory Toolkit •
CLI Reference
Dependency analysis and optimization toolkit for modern JavaScript and TypeScript codebases.
Enforce dependency graph hygiene and remove unused code with a very fast CLI.
As codebases scale, maintaining a mental map of dependencies becomes impossible. Rev-dep is a high-speed static analysis tool designed to enforce architecture integrity and dependency hygiene across large-scale JS/TS projects.
Think of Rev-dep as a high-speed linter for your dependency graph.
Consolidate fragmented, sequential checks from multiple slow tools into a single, high-performance engine. Rev-dep executes a full suite of governance checks—including circularity, orphans, module boundaries and more, in one parallelized pass. Implemented in Go to bypass the performance bottlenecks of Node-based analysis, it can audit a 500k+ LoC project in approximately 500ms.
Automated Codebase Governance
Rev-dep moves beyond passive scanning to active enforcement, answering (and failing CI for) the hard questions:
- Architecture Integrity: “Is my ‘Domain A’ illegally importing from ‘Domain B’?”.
- Dead Code & Bloat: “Are these files unreachable, or are these
node_modulesunused?”. - Refactoring Safety: “Which entry points actually use this utility, and are there circular chains?”.
- Workspace Hygiene: “Are my imports consistent and are all dependencies declared?”.
Rev-dep serves as a high-speed gatekeeper for your CI, ensuring your dependency graph remains lean and your architecture stays intact as you iterate.
🏗️ First-class monorepo support
Designed for modern workspaces (pnpm, yarn, npm). Rev-dep natively resolves package.json exports/imports maps, TypeScript aliases and traces dependencies across package boundaries.
🛡️ Config-Based Codebase Governance
Move beyond passive scanning. Use the configuration engine to enforce Module Boundaries and Import Conventions. Execute a full suite of hygiene checks (circularity, orphans, unused modules and more) in a single, parallelized pass that serves as a high-speed gatekeeper for your CI.
CLI toolkit that helps debug issues with dependencies between files. Understand transitive relation between files and fix issues.
⚡ Built for Speed and CI Efficiency
Implemented in Go to eliminate the performance tax of Node-based analysis. By processing files in parallel, Rev-dep offers 10x-200x faster execution than alternatives, significantly reducing CI costs and developer wait-states.
Rev-dep can audit a 500k+ LoC project in around 500ms.
See the performance comparison
Governance and maintenance (config-based) 🛡️
Use rev-dep config run to execute multiple checks in one pass for all packages.
Available checks:
moduleBoundaries– enforce architecture boundaries between modules.importConventions– enforce import style conventions (offers autofix).unusedExportsDetection– detect exports that are never used (offers autofix).orphanFilesDetection– detect dead/orphan files (offers autofix).unusedNodeModulesDetection– detect dependencies declared but not used.missingNodeModulesDetection– detect imports missing from package json.unresolvedImportsDetection– detect unresolved import requests.circularImportsDetection– detect circular imports.devDepsUsageOnProdDetection– detect dev dependencies used in production code.restrictedImportsDetection– block importing denied files/modules from selected entry points.
Exploratory analysis (CLI-based) 🔍
Use CLI commands for ad-hoc dependency exploration:
entry-points– discover project entry points.files– list dependency tree files for a given entry point.resolve– trace dependency paths between files (who imports this file).imported-by– list direct importers of a file.circular– list circular dependency chains.node-modules– inspectused,unused,missing, andinstallednode modules.lines-of-code– count effective LOC.list-cwd-files– list all source code files in CWD
Install locally to set up project check scripts
Create config file for a quick start:
Install globally to use as a CLI tool:
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
Config-Based Checks 🛡️
Rev-dep provides a configuration system for orchestrating project checks. The config approach is designed for speed and is the preferred way of implementing project checks because it can execute all checks in a single pass, significantly faster than multiple running individual commands separately.
Available checks are:
moduleBoundaries– enforce architecture boundaries between modules.importConventions– enforce import style conventions (offers autofix).unusedExportsDetection– detect exports that are never used (offers autofix).orphanFilesDetection– detect dead/orphan files (offers autofix).unusedNodeModulesDetection– detect dependencies declared but not used.missingNodeModulesDetection– detect imports missing from package json.unresolvedImportsDetection– detect unresolved import requests.circularImportsDetection– detect circular imports.devDepsUsageOnProdDetection– detect dev dependencies used in production code.restrictedImportsDetection– block importing denied files/modules from selected entry points.
Checks are grouped in rules. You can have multiple rules, eg. for each monorepo package.
Initialize a configuration file in your project:
# Create a default configuration file
rev-dep config init
Behavior of rev-dep config init:
- Monorepo root: Running
rev-dep config initat the workspace root creates a root rule and a rule for each discovered workspace package. - Monorepo workspace package or regular projects: Running
rev-dep config initinside a directory creates config with a single rule withpath: "."for this directory.
Run all configured checks (dry run, not fixes applied yet):
# Execute all rules and checks defined in the config
rev-dep config run
List all detected issues:
# Lists all detected issues, by default lists first five issues for each check
rev-dep config run --list-all-issues
Fix all fixable checks:
# Fix checks configured with autofix
rev-dep config run --fix
The configuration file (rev-dep.config.json(c) or .rev-dep.config.json(c)) allows you to define multiple rules, each targeting different parts of your codebase with specific checks enabled.
Quick Start Configuration
Comprehensive Config Example
Here’s a comprehensive example showing all available properties:
configVersion(required): Configuration version string$schema(optional): JSON schema reference for validationconditionNames(optional): Array of condition names for exports resolutionignoreFiles(optional): Global file patterns to ignore across all rules. Git ignored files are skipped by default.rules(required): Array of rule objects
Each rule can contain the following properties:
path(required): Target directory path for this rule (either.or path starting with sub directory name)followMonorepoPackages(optional): Enable monorepo package resolution (default: true)moduleBoundaries(optional): Array of module boundary rulescircularImportsDetection(optional): Circular import detection configurationorphanFilesDetection(optional): Orphan files detection configurationunusedNodeModulesDetection(optional): Unused node modules detection configurationmissingNodeModulesDetection(optional): Missing node modules detection configurationunusedExportsDetection(optional): Unused exports detection configurationunresolvedImportsDetection(optional): Unresolved imports detection configurationdevDepsUsageOnProdDetection(optional): Restricted dev dependencies usage detection configurationrestrictedImportsDetection(optional): Restrict importing denied files/modules from selected entry pointsimportConventions(optional): Array of import convention rules
Module Boundary Properties
name(required): Name of the boundarypattern(required): Glob pattern for files in this boundaryallow(optional): Array of allowed import patternsdeny(optional): Array of denied import patterns (overrides allow)
Import Convention Properties
rule(required): Type of the rule, currently onlyrelative-internal-absolute-externalautofix(optional): Whether to automatically fix import convention violations (default: false)domains(required): Array of domain definitions. Can be a string (glob pattern) or an object with:path(required): Directory with the domain filesalias(optional): Alias to be used for absolute imports of code from this domainenabled(optional): Set tofalseto skip checks for this domain (default: true)
Detection Options Properties
CircularImportsDetection:
enabled(required): Enable/disable circular import detectionignoreTypeImports(optional): Exclude type-only imports when building graph (default: false)
OrphanFilesDetection:
enabled(required): Enable/disable orphan files detectionvalidEntryPoints(optional): Array of valid entry point patterns (eg. [“src/index.ts”, “src/main.ts”])ignoreTypeImports(optional): Exclude type-only imports when building graph (default: false)graphExclude(optional): File patterns to exclude from graph analysisautofix(optional): Delete detected orphan files automatically when runningrev-dep config run --fix(default: false)
UnusedNodeModulesDetection:
enabled(required): Enable/disable unused modules detectionincludeModules(optional): Module patterns to include in analysisexcludeModules(optional): Module patterns to exclude from analysispkgJsonFieldsWithBinaries(optional): Package.json fields containing binary references (eg. lint-staged). Performs plain-text lookupfilesWithBinaries(optional): File patterns to search for binary usage. Performs plain-text lookupfilesWithModules(optional): Non JS/TS file patterns to search for module imports (eg. shell scripts). Performs plain-text lookupoutputType(optional): Output format – “list”, “groupByModule”, “groupByFile”
MissingNodeModulesDetection:
enabled(required): Enable/disable missing modules detectionincludeModules(optional): Module patterns to include in analysisexcludeModules(optional): Module patterns to exclude from analysisoutputType(optional): Output format – “list”, “groupByModule”, “groupByFile”, “groupByModuleFilesCount”
UnusedExportsDetection:
enabled(required): Enable/disable unused exports detectionvalidEntryPoints(optional): Glob patterns for files whose exports are never reported as unused (eg. [“index.ts”, “src/public-api.ts”])ignoreTypeExports(optional): Skipexport type/export interfacefrom analysis (default: false)graphExclude(optional): File patterns to exclude from unused exports analysis
UnresolvedImportsDetection:
enabled(required): Enable/disable unresolved imports detectionignore(optional): Map of file path (relative to rule path directory) to exact import request to suppressignoreFiles(optional): File path globs; all unresolved imports from matching files are suppressedignoreImports(optional): Import requests to suppress globally in unresolved results
DevDepsUsageOnProd:
enabled(required): Enable/disable restricted dev dependencies usage detectionprodEntryPoints(optional): Production entry point patterns to trace dependencies from (eg. [“src/pages/**/*.tsx”, “src/main.tsx”])ignoreTypeImports(optional): Exclude type-only imports from graph traversal and module matching (default: false)
RestrictedImportsDetection:
enabled(required): Enable/disable restricted imports detectionentryPoints(required when enabled): Entry point patterns used to build reachable dependency graphdenyFiles(optional): Denied file path patterns (eg. [“**/*.tsx”])denyModules(optional): Denied module patterns (eg. [“react”, “react-*”])ignoreMatches(optional): File/module patterns to suppress from restricted import resultsignoreTypeImports(optional): Exclude type-only imports from traversal (default: false)
The configuration approach provides significant performance advantages:
- Single Dependency Tree Build: Builds one comprehensive dependency tree for all rules
- Parallel Rule Execution: Processes multiple rules simultaneously
- Parallel Check Execution: Runs all enabled checks within each rule in parallel
- Optimized File Discovery: Discovers files once and reuses across all checks
This makes config-based checks faster than running individual commands sequentially, especially for large codebases with multiple sub packages.
Practical examples show how to use rev-dep CLI commands to explore, debug or build code quality checks for your project.
How to identify where a file is used in the project
rev-dep resolve --file path/to/file.ts
You’ll see all entry points that implicitly require that file, along with resolution paths.
How to check if a file is used
rev-dep resolve --file path/to/file.ts --compact-summary
Shows how many entry points indirectly depend on the file.
How to identify dead files
Exclude framework entry points if needed using --result-exclude.
For example exclude Next.js valid entry points when using pages router, exclude scripts directory – scripts are valid entry-points and exclude all test files:
rev-dep entry-points --result-exclude "pages/**","scripts/**","**/*.test.*"
How to list all files imported by an entry point
rev-dep files --entry-point path/to/file.ts
Useful for identifying heavy components or unintended dependencies.
How to reduce unnecessary imports for an entry point
-
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
How to detect circular dependencies
How to find unused node modules
rev-dep node-modules unused
How to find missing node modules
rev-dep node-modules missing
How to check node_modules space usage
rev-dep node-modules dirs-size
Working with Monorepo 🏗️
Rev-dep provides first-class support for monorepo projects, enabling accurate dependency analysis across workspace packages.
followMonorepoPackages Flag
The --follow-monorepo-packages flag enables resolution of imports from monorepo workspace packages. By default, this flag is set to false to maintain compatibility with single-package projects.
# Enable monorepo package resolution
rev-dep circular --follow-monorepo-packages
rev-dep resolve --file src/utils.ts --follow-monorepo-packages
rev-dep entry-points --follow-monorepo-packages
When enabled, rev-dep will:
- Detect workspace packages automatically by scanning for monorepo configuration
- Resolve imports between packages within the workspace
- Follow package.json exports for proper module resolution
Rev-dep fully supports the exports field in package.json files, which is the standard way to define package entry points in modern Node.js projects.
The exports map support includes:
- Conditional exports using conditions like
node,import,default, and custom conditions - Wildcard patterns for flexible subpath mapping
- Sugar syntax for simple main export definitions
- Nested conditions for complex resolution scenarios
To control which conditional exports are resolved, use the --condition-names flag. This allows you to specify the priority of conditions when resolving package exports:
# Resolve exports for different environments
rev-dep circular --condition-names=node,import,default
rev-dep resolve --file src/utils.ts --condition-names=import,node
rev-dep entry-points --condition-names=default,node,import
The conditions are processed in the order specified, with the first matching condition being used. Common conditions include:
node– Node.js environmentimport– ES modulesrequire– CommonJSdefault– Fallback condition- Custom conditions specific to your project or build tools
Example package.json with exports:
{
"name": "@myorg/utils",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"default": "./dist/index.js"
},
"./helpers": "./dist/helpers.js",
"./types/*": "./dist/types/*.d.ts"
}
}
-
Monorepo Detection: When
followMonorepoPackagesis enabled, rev-dep scans for workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.) -
Package Resolution: Imports to workspace packages are resolved using the package’s exports configuration, falling back to main/module fields when exports are not defined
-
Dependency Validation: The tool validates that cross-package imports are only allowed when the target package is listed in the consumer’s dependencies or devDependencies
-
Path Resolution: All paths are resolved relative to their respective package roots, ensuring accurate dependency tracking across the entire monorepo
This makes rev-dep particularly effective for large-scale monorepo projects where understanding cross-package dependencies is crucial for maintaining code quality and architecture.
Performance comparison ⚡
Rev-dep can perform multiple checks on 500k+ LoC monorepo with several sub-packages in around 500ms.
It outperforms Madge, dpdm, dependency-cruiser, skott, knip, depcheck and other similar tools.
Here is a performance comparison of specific tasks between rev-dep and alternatives:
| Task | Execution Time [ms] | Alternative | Alternative Time [ms] | Slower Than Rev-dep |
|---|---|---|---|---|
| Find circular dependencies | 289 | dpdm-fast | 7061 | 24x |
| Find unused exports | 303 | knip | 6606 | 22x |
| Find unused files | 277 | knip | 6596 | 23x |
| Find unused node modules | 287 | knip | 6572 | 22x |
| Find missing node modules | 270 | knip | 6568 | 24x |
| 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
Circular check performance comparison
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 script using skott 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 |
How to detect dev dependencies used in production code
When devDepsUsageOnProdDetection is enabled in your config, rev-dep will:
- Trace dependency graphs from your specified production entry points
- Identify all files reachable from those entry points
- Check if any imported modules are listed in
devDependenciesin package.json - Report violations showing which dev dependencies are used where
Example Output:
❌ Restricted Dev Dependencies Usage Issues (2):
lodash (dev dependency)
- src/components/Button.tsx (from entry point: src/pages/index.tsx)
- src/utils/helpers.ts (from entry point: src/pages/index.tsx)
eslint (dev dependency)
- src/config/eslint-config.js (from entry point: src/server.ts)
Important Notes:
- Type-only imports (e.g.,
import type { ReactNode } from 'react') are ignored whenignoreTypeImportsis enabled - Only dependencies from
devDependenciesin package.json are flagged - Production dependencies from
dependenciesare allowed - Helps prevent runtime failures in production builds
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 --ignore-types-imports
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-c, --cwd string Working directory for the command (default "$PWD")
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-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)
-v, --verbose Show warnings and verbose output
Create and execute rev-dep configuration files
Commands for creating and executing rev-dep configuration files.
-c, --cwd string Working directory (default "$PWD")
-h, --help help for config
Execute all checks defined in (.)rev-dep.config.json(c)
Process (.)rev-dep.config.json(c) and execute all enabled checks (circular imports, orphan files, module boundaries, import conventions, node modules, unused exports, unresolved imports, restricted imports and restricted dev deps usage) per rule.
rev-dep config run [flags]
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-c, --cwd string Working directory (default "$PWD")
--fix Automatically fix fixable issues
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-h, --help help for run
--list-all-issues List all issues instead of limiting output
--package-json string Path to package.json (default: ./package.json)
--rules strings Subset of rules to run (comma-separated list of rule paths)
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose output
Initialize a new rev-dep.config.json file
Create a new rev-dep.config.json configuration file in the current directory with default settings.
rev-dep config init [flags]
-c, --cwd string Working directory (default "$PWD")
-h, --help help for init
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
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-n, --count Only display the number of entry points found
-c, --cwd string Working directory for the command (default "$PWD")
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
--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)
-v, --verbose Show warnings and verbose output
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 --entry-point src/index.ts
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-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)
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-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)
-v, --verbose Show warnings and verbose output
List all files that directly import the specified file
Finds and lists all files in the project that directly import the specified file.
This is useful for understanding the impact of changes to a particular file.
rev-dep imported-by [flags]
rev-dep imported-by --file src/utils/helpers.ts
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-n, --count Only display the count of importing files
-c, --cwd string Working directory for the command (default "$PWD")
-f, --file string Target file to find importers for (required)
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-h, --help help for imported-by
--list-imports List the import identifiers used by each file
--package-json string Path to package.json (default: ./package.json)
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose output
Count actual lines of code in the project excluding comments and blank lines
rev-dep lines-of-code [flags]
-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
rev-dep node-modules dirs-size
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
rev-dep node-modules installed-duplicates
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
rev-dep node-modules installed
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
rev-dep node-modules missing
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
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-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
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
--group-by-file Organize output by project file path
--group-by-module Organize output by npm package name
--group-by-module-files-count Organize output by npm package name and show count of files using it
-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)
-v, --verbose Show warnings and verbose output
--zero-exit-code Use this flag to always return zero exit code
rev-dep node-modules unused
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/*
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-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
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-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)
-v, --verbose Show warnings and verbose output
--zero-exit-code Use this flag to always return zero exit code
rev-dep node-modules used
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
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-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
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
--group-by-entry-point Organize output by entry point file path
--group-by-entry-point-modules-count Organize output by entry point and show count of unique modules
--group-by-file Organize output by project file path
--group-by-module Organize output by npm package name
--group-by-module-entry-points-count Organize output by npm package name and show count of entry points using it
--group-by-module-files-count Organize output by npm package name and show count of files using it
--group-by-module-show-entry-points Organize output by npm package name and list entry points using it
-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)
-v, --verbose Show warnings and verbose output
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 -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
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-c, --cwd string Working directory for the command (default "$PWD")
-p, --entry-points strings Entry point file(s) or glob pattern(s) to start analysis from (default: auto-detected)
-f, --file string Target file to check for dependencies
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
--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
--module string Target node module name to check for dependencies
--package-json string Path to package.json (default: ./package.json)
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose output
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.
Reverse dependency (or “dependents”)
Files that import a given file.
Useful for answering: “What breaks if I change or delete this file?”
Import graph / Dependency graph
A visual representation of how files or modules import each other.
Missing dependency / unused node module
A module that your code imports but is not listed in package.json.
Unused dependency / unused node module
A dependency listed in package.json that is never imported in the source code.
Root directory / Project root
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 ⭐!
{💬|⚡|🔥} **What’s your take?**
Share your thoughts in the comments below!
#️⃣ **#jayurevdep #Dependency #analysis #optimization #toolkit #modern #JavaScript #TypeScript #codebases #Enforce #dependency #graph #hygiene #remove #unused #code #fast #CLI**
🕒 **Posted on**: 1772135669
🌟 **Want more?** Click here for more info! 🌟

{ "configVersion": "1.5", "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.5.schema.json?raw=true", // enables json autocompletion "conditionNames": ["import", "default"], "ignoreFiles": ["**/*.test.*"], "rules": [ { "path": ".", "followMonorepoPackages": true, "moduleBoundaries": [ { "name": "ui-components", "pattern": "src/components/**/*", "allow": ["src/utils/**/*", "src/types/**/*"], "deny": ["src/api/**/*"] }, { "name": "api-layer", "pattern": "src/api/**/*", "allow": ["src/utils/**/*", "src/types/**/*"], "deny": ["src/components/**/*"] } ], "importConventions": [ { "rule": "relative-internal-absolute-external", "autofix": true, "domains": [ { "path": "src/features/auth", "alias": "@auth", "enabled": true }, { "path": "src/shared/ui", "alias": "@ui-kit", "enabled": false // checks disabled for this domain, but alias is still used for absolute imports from other domains } ] } ], "circularImportsDetection": { "enabled": true, "ignoreTypeImports": true }, "orphanFilesDetection": { "enabled": true, "validEntryPoints": ["src/index.ts", "src/app.ts"], "ignoreTypeImports": true, "graphExclude": ["**/*.test.*", "**/stories/**/*"], "autofix": true }, "unusedNodeModulesDetection": { "enabled": true, "includeModules": ["@myorg/**"], "excludeModules": ["@types/**"], "pkgJsonFieldsWithBinaries": ["scripts", "bin"], "filesWithBinaries": ["scripts/check-something.sh"], "filesWithModules": [".storybook/main.ts"], "outputType": "groupByModule" }, "missingNodeModulesDetection": { "enabled": true, "includeModules": ["lodash", "axios"], "excludeModules": ["@types/**"], "outputType": "groupByFile" }, "unusedExportsDetection": { "enabled": true, "validEntryPoints": ["src/index.ts"], "ignoreTypeExports": true, "graphExclude": ["**/*.stories.tsx"], "autofix": true }, "unresolvedImportsDetection": { "enabled": true, "ignore": { "src/index.ts": "legacy-unresolved-module" }, "ignoreFiles": ["**/*.generated.ts"], "ignoreImports": ["@internal/dev-only"] }, "devDepsUsageOnProdDetection": { "enabled": true, "prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx", "src/server.ts"], "ignoreTypeImports": true }, "restrictedImportsDetection": { "enabled": true, "entryPoints": ["src/server.ts", "src/server/**/*.ts"], "denyFiles": ["**/*.tsx"], "denyModules": ["react", "react-*"], "ignoreMatches": ["src/server/allowed-view.tsx", "react-awsome-lib"], "ignoreTypeImports": true } } ] }