3 ms·
It's actually not possible due to the way Node looks up dependencies. You could have a situation like: node_modules/ a/ node_modules/ c/ (1
by Touche 10y ago
It's actually not possible due to the way Node looks up dependencies. You could have a situation like:
node_modules/
a/
node_modules/
c/ (1.0.0)
b/
node_modules/
c/ (1.0.0)
c/ (2.0.0)
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.
- rplnt 10y agoYou 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.
- ksherlock 10y agoIt's entirely possible with symbolic links. https://github.com/rstacruz/pnpm https://github.com/rstacruz/pnpm
- RossM 10y agoI've built a fairly hacky solution to this before (for a different package manager) - it can be pretty simple: node_modules/ versions/ a@1.0.0 node_modules/ c -> ../../c@1.0.0 b@1.0.0 node_modules/ c -> ../../c@1.0.0 c@1.0.0/ c@2.0.0/ a -> versions/a@1.0.0 b -> versions/b@1.0.0 c -> versions/c@2.0.0
- Touche 10y agoSome other people have linked to npm alternatives ied and pnpm which do essentially this.