Live data from Hacker News

Show HN: Node.js node_modules file pruning

github.com

11–20 of 66 posts

Re: Show HN: Node.js node_modules file pruning

#11

This is completely useless because npm still downloads those files and the hdd space is pretty negligeble. It should def go under the category of troll driven development. This might be useful for docker images that will be distrubuted and will be downloaded a lot, but even there it's a stretch. That being said, it would be great if npm had some functionality around packaging only the necessary files for actually run…

I guess there is the "files" and ".npmignore" which handle these, but they don't seem to be widely used in the community.

Re: Show HN: Node.js node_modules file pruning

#13

This is completely useless because npm still downloads those files and the hdd space is pretty negligeble. It should def go under the category of troll driven development. This might be useful for docker images that will be distrubuted and will be downloaded a lot, but even there it's a stretch. That being said, it would be great if npm had some functionality around packaging only the necessary files for actually run…

It's for Lambda

Maybe documentation should include uses cases? Newer users to npm + node might think this does something different. Just a suggestions.

Re: Show HN: Node.js node_modules file pruning

#14
Awesome idea. Especially if you’re packaging your projects via something like Docker this can shave hundreds of megabytes. (Even if you’re using the Docker layer cache, any change to your dependencies will bust the entire node_modules cache.)

The caveats is that this won’t work 100% of the time. There will be a dependency deep down in the tree that needs to read a markdown file from the file system or something of that sort. These issues could be hard to debug if this tool doesn’t provide good visibility into what’s being deleted.

Re: Show HN: Node.js node_modules file pruning

#15
Love it. Saved 600MB... and test cases still passed :)

I ported it to bash really quick, as thats probably easier for people to drop into their dotfiles if they don't have a Golang env setup.

https://gist.github.com/gpittarelli/64d1e9b7c1a4af762ec467b1...

If we all just do our part and send a PR setting up .npmignore for one or two of these projects, maybe we won't need this anymore

Re: Show HN: Node.js node_modules file pruning

#16
post #8

Shouldn't this be handled entirely by npm? If these files are unnecessary why do they get downloaded in the first place?

What gave you a reason to believe npm was well-architected?

It's more an issue with the modules authors, npm already has a documented way to exclude files from being published.

Furthermore, it would be quite irritating if it started assuming specific file extensions are forbidden instead of using the explicit list provided by the author.

Re: Show HN: Node.js node_modules file pruning

#18

Shouldn't this be handled entirely by npm? If these files are unnecessary why do they get downloaded in the first place?

Ideally people use the "files" array. It might be nice if someone writes a bot to go around and fix large packages by adding that.

Many authors are strangely against it for some reason. One time I sorted my node_modules by size and opened issues for the top offenders, you can see their resistance here:

https://github.com/crypto-browserify/sha.js/issues/5

https://github.com/medikoo/es5-ext/issues/11

Post reply on HN