No disrespect to TJ (he did many awesome projects I use almost daily), but wouldn't simple: 'find node_modules -not -regex ".*.[js,json]" -delete' do the same job? Why project in go?
Show HN: Node.js node_modules file pruning
41–50 of 66 posts
Re: Show HN: Node.js node_modules file pruning
#42Usually I don't care about what language an executable is written in. After all, as a user I'm just interested in whether it executes or not. But these small-software situations amaze me. Someone with a node_modules problem will have readily available sh, node and maybe python. So why golang? What could those not do, or golang can do better to such extent that it trumps availability? Similarly there's a price to pay…
Re: Show HN: Node.js node_modules file pruning
#43Love 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
#44Shouldn't this be handled entirely by npm? If these files are unnecessary why do they get downloaded in the first place?
Re: Show HN: Node.js node_modules file pruning
#45Re: Show HN: Node.js node_modules file pruning
#46Love 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
Great. I wrapped your script into npm package https://www.npmjs.com/package/node-prune
https://www.npmjs.com/package/download-size
The tool is available online too:
Re: Show HN: Node.js node_modules file pruning
#47Awesome 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 th…
Re: Show HN: Node.js node_modules file pruning
#48Usually I don't care about what language an executable is written in. After all, as a user I'm just interested in whether it executes or not. But these small-software situations amaze me. Someone with a node_modules problem will have readily available sh, node and maybe python. So why golang? What could those not do, or golang can do better to such extent that it trumps availability? Similarly there's a price to pay…
Man it's free code, you're reading into this far too much.
Re: Show HN: Node.js node_modules file pruning
#49Rather than two giant 440px high images consisting of tiny text in the readme I'd quite love to read exactly what it does and why. Does it prune files in modules that are not needed? If so what heuristics does it use to prune files? Or does it prune modules that are not needed? Reading the code[1] it appears to delete directories and extensions based on a blacklist. 1. https://github.com/tj/node-prune/blob/master/pru…
It looks like it removes the files necessary for "npm install" assuming that the module will do npm install immediately when you install it. This is not true for all cases though..which is why the files should be kept around. Disk space is cheap. This isn't bad for deployments though.