I'm new to npm here, so maybe I don't get something. I understand that npm can install modules in an npm_modules
directory that is local to the project, or by using --global
you can install it in a machine-wide location.
Other than for some temporary convenience, why would you install any package globally? For example, I see all sorts of npm configurations / setups that do a global install of typescript. But if I have 5 projects on my machine and 3 of them use different versions of typescript, that is not good...right?
My experience with package management is from the Java/Maven world where all modules are installed in a global location (~/.m2/repository), but to reference ANYTHING (as a cmd/tool/plugin or as a dependency) you need to specify the version number. Thus you get the best of both worlds -- elimination of duplicate package installations and perfectly reproducible builds. I would have thought npm would, in its own way, accomplish the same thing.
What am I missing?