A simple Java tool to find and analyze node_modules directories in your system, demonstrating modern Java features for scripting.
NodeSnitch helps developers identify and manage disk space usage by node_modules directories across their system. It's also a showcase for modern Java features that make the language more accessible for scripting and quick tools.
This tool demonstrates the use of JEP 445: Unnamed Classes and Instance Main Methods, which allows for simpler, script-like Java code without the traditional class boilerplate. This makes Java more approachable for beginners and better suited for small utilities.
JEP 330: Launch Single-File Source-Code Programs introduced support for running Java source files directly using a shebang (#!) line. This allows Java files to be executed like shell scripts, making it more convenient for command-line tools.
- Java 23 or later
- Unix-like operating system (Linux, macOS)
- Read access to your home directory
Simply run the script from your terminal:
- Clone the project
- Make it executable:
cd nodesnitch chmod +x ./nodesnitch ./nodesnitch
The tool will:
- Search your home directory for
node_modules
folders - Calculate the size of each directory
- Display results sorted by size (largest first)
Scanning for node_modules directories...
Found node_modules:
/Users/dev/project1/node_modules (1.2 GB)
/Users/dev/project2/node_modules (856 MB)
/Users/dev/test/node_modules (234 MB)
Total space used: 2.29 GB
MIT License