We have a very unique deployment/shipment situation. We are building our software into an archive and shipping it across the ocean to Africa where the client's machine does not have access to Internet. Or VERY LIMITED and slow connection. Imagine 56K with 75% pack drop rate.
We are using bower and npm package manager to manage the frontend and backend packages.
With bower we can just download the packages, concat the files and once built we can just remove the bower_components folder. This reduced the deployment archive by 60%.
Next step is to cleanup the node_modules folder.
tl;dr Is there anyway to remove unneeded files from the node_modules folder, ie) bcrypt intermediate build files, etc so that we only keep the ABSOLUTELY necessary files.
The closest thing npm has is the dedupe command. That will remove duplicate copies of npm packages. However, it is very common for npm modules to ship with a lot of files (documentation, tests, icons) that are not strictly necessary at runtime. I'm not aware of any existing tool to trim these out as that process would be fairly non-deterministic. You could use some of the parsing/analysis modules that form the guts of browserify to walk your program and find all the actual javascript files it loads and omit anything not in that graph, but I'm not aware of a pre-existing tool that does this. If you were to build something, I'm sure others would find it useful, though.