Scan node_modules and rank packages by bloat (size) - find which dependencies are taking up the most disk space
npm install node-bloat-scannerA Node.js CLI tool that scans your node_modules directory and ranks packages by their size (bloat), helping you identify which dependencies are taking up the most disk space.
- š Scans all packages in node_modules (including scoped packages)
- š Ranks packages by disk size (largest = most bloated)
- š Shows file count, version, and formatted sizes
- š¾ Optional JSON export for further analysis
- ā” Fast recursive directory scanning
- š¦ Installable as npm package - use with npx
``bashRun directly with npx (no installation needed)
npx node-bloat-scanner
$3
`bash
Clone or download the repository
npm installRun locally
npm start
or
node scanner.js
`Usage
$3
`bash
Scan node_modules in current directory
npx node-bloat-scanner
`$3
`bash
Limit number of results shown
npx node-bloat-scanner --limit 20
or
npx node-bloat-scanner -l 20Export results to JSON
npx node-bloat-scanner --json
or
npx node-bloat-scanner -jScan a specific path
npx node-bloat-scanner /path/to/projectShow help
npx node-bloat-scanner --help
`Output Example
`
š Scanning node_modules...Found 245 items in node_modules
š Analyzing package sizes...
Processed: 245 packages...
ā
Scan complete!
====================================================================================================
š¦ TOP 50 MOST BLOATED PACKAGES (by size)
====================================================================================================
Rank Package Name Size Files Version
----------------------------------------------------------------------------------------------------
1 webpack 45.2 MB 1,234 5.88.0
2 @types/node 12.5 MB 456 18.15.0
3 typescript 8.3 MB 234 5.0.0
...
====================================================================================================
š Summary:
Total packages scanned: 245
Total size: 156.7 MB
Average package size: 639.2 KB
Top 50 packages account for: 142.3 MB
====================================================================================================
`How It Works
1. Scans the
node_modules directory recursively
2. Calculates the total size of each package (excluding nested node_modules)
3. Counts the number of files in each package
4. Extracts package metadata from package.json (name, version, description)
5. Ranks packages by size (largest first)
6. Displays results in a formatted tableNotes
- The script skips nested
node_modules directories to avoid double-counting
- Scoped packages (e.g., @types/node) are handled correctly
- Permission errors are handled gracefully
- The .bin` directory is excluded from the scanMIT