
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Remove unwanted files and directories from your node_modules folder
Diarrhea is a fork of ModClean with some optimizations.
This documentation is for diarrhea 3.x which requires Node v8+, if you need to support older versions, use ModClean instead.
If you need to support versions older then v6.9+, use ModClean 1.3.0 instead.
Diarrhea is a utility that finds and removes unnecessary files and folders from your node_modules
directory based on predefined and custom glob patterns. This utility comes with both a CLI and a programmatic API to provide customization for your environment. Diarrhea is used and tested in an Enterprise environment on a daily basis.
There are a few different reasons why you would want to use Diarrhea:
node_modules
directory with your application into version control. This is due to compatibility, vetting and vunerability scanning rules for open source software. This can lead to issues with project size, checking out/pulling changes and the infamous 255 character path limit if you're unlucky enough to be on Windows or SVN.The :cake: is a lie, but the Benchmarks are not.
Diarrhea scans the node_modules
directory of your choosing, finding all files and folders that match the defined patterns and deleting them. Both the CLI and the programmatic API provides all the options needed to customize this process to your requirements. Depending on the number of modules your app requires, files can be reduced anywhere from hundreds to thousands and disk space can be reduced considerably.
(File and disk space reduction can also be different between the version of NPM and Operating System)
IMPORTANT This module has been heavily tested in an enterprise environment used for large enterprise applications. The provided patterns in modclean-patterns-default have worked very well when cleaning up useless files in many popular modules. There are hundreds of thousands of modules in NPM and I cannot simply cover them all. If you are using Diarrhea for the first time on your application, you should create a copy of the application so you can ensure it still runs properly after running Diarrhea. The patterns are set in a way to ensure no crutial module files are removed, although there could be one-off cases where a module could be affected and that's why I am stressing that testing and backups are important. If you find any files that should be removed, please create a pull request to modclean-patterns-default or create your own patterns plugin to share with the community.
So how well does this module work? If we npm install sails
and run Diarrhea on it, here are the results:
All tests ran on macOS 10.12.3 with Node v6.9.1 and NPM v4.0.5
diarrhea -n default:safe
or diarrhea
Total Files | Total Folders | Total Size | |
---|---|---|---|
Before Diarrhea | 16,179 | 1,941 | 71.24 MB |
After Diarrhea | 12,192 | 1,503 | 59.35 MB |
Reduced | 3,987 | 438 | 11.88 MB |
diarrhea -n default:safe,default:caution
Total Files | Total Folders | Total Size | |
---|---|---|---|
Before Diarrhea | 16,179 | 1,941 | 71.24 MB |
After Diarrhea | 11,941 | 1,473 | 55.28 MB |
Reduced | 4,238 | 468 | 15.95 MB |
diarrhea --patterns="default:*"
Total Files | Total Folders | Total Size | |
---|---|---|---|
Before Diarrhea | 16,179 | 1,941 | 71.24 MB |
After Diarrhea | 11,684 | 1,444 | 51.76 MB |
Reduced | 4,495 | 497 | 19.47 MB |
That makes a huge difference in the amount of files and disk space.
View additional benchmarks on the Wiki: Benchmarks. If you would like to run some of your own benchmarks, you can use modclean-benchmark.
Install locally
npm install diarrhea --save
Install globally (CLI)
npm install diarrhea -g
If you find any bugs with either Diarrhea or the CLI Utility, please feel free to open an issue. Any feature requests may also be posted in the issues.
Diarrhea and ModClean are licensed under the MIT license. Please see LICENSE in the repository for the full text.
3.0.5
FAQs
Remove unwanted files and directories from your node_modules folder
The npm package diarrhea receives a total of 137 weekly downloads. As such, diarrhea popularity was classified as not popular.
We found that diarrhea demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.