Re:Huge no. of files for Angular 2
by Touche on Tuesday August 02, 2016 @07:47AM
(#12209196)
It's actually not possible due to the way Node looks up dependencies. You could have a situation like:
Both a and b depend on c version 1.0.0, but since there's a version 2.0.0 in the root node_modules folder c can't be placed there, and has to be duplicated in a and b's own node_modules folder, otherwise Node couldn't find it for each of them.
[ Parent
| on HN ]
It's entirely possible with symbolic links. https://github.com/rstacruz/pnpm
You could use links, version in names, ... You'd just have problem to take out one submodule I guess, but I doubt that's a use case anywhere.
I've built a fairly hacky solution to this before (for a different package manager) - it can be pretty simple:
node_modules/
versions/
[email protected]
node_modules/
c -> ../../[email protected]
[email protected]
node_modules/
c -> ../../[email protected]
[email protected]/
[email protected]/
a -> versions/[email protected]
b -> versions/[email protected]
c -> versions/[email protected]