I have done Angular 2 application using npm, when the app has just 1 mb size, the node_modules folder consumes around 90 mb,so Is there any possibility to reduce the node_modules folder size, at least while publishing in IIS?
We can reduce our node modules size by these actions: find and remove all unused dependencies with depcheck. deduplicate all the duplicated dependencies with yarn-deduplicate.
Originally Answered: Why are node_modules so large? The module structure used to be completely nested, meaning multiple versions of the same modules could be nested within each other. This is no longer the case, so module sizes are not as big as they used to be.
npx allows to run npm commands without installing the package. and then you can just run npkill from any directory to delete the node_modules folder. Once the list is displayed, you can navigate using arrow keys and delete the specific node_modules directory by hitting the spacebar.
You could remove your node_modules/ folder and then reinstall the dependencies from package. json. This would erase all installed packages in the current folder and only install the dependencies from package.
I would suggest using grunt-package-minifier
Initially I strip all the package.json, README etc. from node_modules but keep the essential JavaScript files in a structure that can be used by a CommonJS module loader.
Also have a look at reduce-node-modules-bloat.md
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With