I would also assume for very large apps it may improve startup time because you don't have to initialize and retain multiple copies of the same module.
I would also assume for very large apps it may improve startup time because you don't have to initialize and retain multiple copies of the same module.
The allowed/unpredictable duplication can even cause very hard to identify bugs when a peer dependency relies on "instanceof" checks and there are multiple versions of this dependency. I've seen it happen with React and Backbone to name a couple.
If the `npm install` allowed control over install order (instead of just being alphabetical) and there was a way to be notified of incompatibilities that would cause potentially unnecessary duplication that would be at least something that could prevent problems like this from occurring.
I work on a client-side module loader StealJS[1] that implements the npm algorithm (2 and 3) in the browser and 3 makes things worse for us. With NPM 2 we could load a project without causing 404s (except in the cause of require("./folder")) but since NPM 3 says "install order matters" now it's no longer deterministic and 404s are more common.
It would be nice if NPM had some working group to discuss their algorithm and invited in other implementers for feedback.