npm-unused-checker
v1.5.0
Published
CLI to find and remove unused npm packages
Maintainers
Readme
npm-unused-checker
A CLI tool to identify and optionally remove unused dependencies from a JavaScript or TypeScript project.
Features
- Scans your
src/directory for imports and requires - Detects unused packages listed in
dependenciesanddevDependencies - Supports scoped packages and CSS imports (e.g.,
@fortawesome/fontawesome-free/css/all.min.css) - Optional prompt to remove unused packages
Installation
Global install
npm install -g npm-unused-checkerUsage
Scan
npx checkThis will:
- Read your
package.json - Scan all files under the
src/directory - Print a list of unused dependencies (if any)
Suggest you to remove unused packages
After listing unused packages, the tool will prompt:
Do you want to remove them? (y/n):If you choose y, it will run npm uninstall on those packages.
Example
npx checkUnused packages found:
- axios
- moment
Do you want to remove them? (y/n): y
Removing...
Successfully removed unused packages.Notes
- This tool works with JavaScript and TypeScript projects.
- The scan is limited to files under the
src/directory. - Only packages listed in
dependenciesanddevDependenciesare considered.
License
MIT
