Node Module Cleaner (nmcleaner)

Node Modules Cleaner (nmcleaner)
nmcleaner
is a simple command-line tool that helps you clean up all node_modules
directories recursively in a given project directory. It provides options to perform a dry run (just printing the directories without deleting them) and to force deletion even if there are permission errors.
Installation
To install nmcleaner
, you can use Bun as your package manager:
-
Make sure you have Bun installed. If you don't, you can install it by following the instructions on the Bun website.
-
Clone or download the repository.
-
Inside the repository, run the following command to make the script executable :
bun install # to install the dependencies
bun link # to link a local package.
# start to use the tools
nmcleaner ./test/ --dry-run --force
Arguments
[target]
: The target directory where the cleanup should start. If not provided, it defaults to the current directory (.
).
Options
--dry-run
: Runs the tool in dry-run mode. It will print the directories that would be deleted without actually removing anything.-f, --force
: Forces the deletion ofnode_modules
directories, even if there are permission errors.
Example Commands
- Clean the current directory (with
node_modules
removed recursively). - Clean a specific directory (e.g.,
./project
). - Dry run (print the directories that would be deleted without actually deleting them).
- Force deletion (ignore permission errors and force delete).
nmcleaner ./test/ --dry-run --force