@importdevcoffee/clean-deps v1.2.1
@importdevcoffee/clean-deps
๐งน clean-deps
clean-deps is a fast and lightweight CLI-tool for scanning and removing unused dependencies in your Node.js and TypeScript projects. It detects unused import and require statements and lets you clean them up with a simple flag.
Perfect for keeping your codebase clean, lean, production-ready and free from unnecessary bloat.
โจ Features
- Detects unused
dependenciesanddevDependenciesfrom yourpackage.json - Scan your project for actual module usage (imports + script binaries) using the
scancommand Remove unused dependencies automatically with:
Uninstall all unused dependencies by using
--cleanor-c.Want to only uninstall the specified dependencies when using
--clean? Use in addition--specify <deps>or-sExample:
clean-deps scan --clean --specify dep1,dep2,dep3
Want to ignore dependencies and make sure that they arent getting uninstalled? Use in addition
--ignoreExample:
clean-deps scan --clean --ignore dep2,dep3
Want to skip the confirmation dialog when cleaning/deleting? Use
--yesor-y.Example:
clean-deps scan --clean --yes
Works with both JavaScript and TypeScript
๐ฆ Installation
Note: It is highly recommended to install clean-deps with the --save-dev flag.
npm install @importdevcoffee/clean-deps --save-devYou can use your terminal and run the cli-tool from your project directory by using:
npx clean-deps scan [options]Want to create convenient shortcuts? You can add entries to your scripts inside of your package.json.
For example:
"scripts":
{
"scan": "clean-deps scan",
"scan:clean": "clean-deps scan --clean",
"scan:autoclean": "clean-deps scan -c -y",
...
}You can then simply run the script by using npm run scan which will automatically execute the configured command.
Example
Use this command in your terminal, inside of your project:
npx clean-deps scanExpect an output similar to this:
Dependencies from script and imports which are in use:
["dep1", "dep2"
"dep3", "dep4",
... ...
]
Unused: []
Found 0 unused dependencies.Flag Representation in Table-format
Flags
| Flag | Description |
|---|---|
--clean, -c | Cleanup/uninstall your dependecies |
--specify, -s | Specify which unused dependencies you want to remove |
--yes, -y | Skip confirmation dialog before deleting |
--ignore | Ignore specific dependencies from being removed |
๐ License
This project is licensed under the MIT License
๐ Contributing
Found a bug or want to improve this tool? PRs and issues are always welcome.