What do I do about it? And why #121
-
Hi there, I saw someone tweet about this and thought I'd give it a try. I'm just a bit confused when it's an issue to have multiple versions of a package and how to fix it. Let's say I have 3 versions of Typescript:
What should I do about this? I can try updating |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @kristojorg! One of the original goals of the node_module resolution algorithm was to enable multiple versions of the same module. This was (and probably still is) one of the biggest strengths of node. It enabled a library to declare its dependencies and always work correctly regardless of other dependencies that are installed in the same workspace. The tradeoff of this approach is that you need to download a lot of different versions of the same module, and since the whole industry is built this way, you get a very heavy To mitigate that, package managers designed multiple different approaches to deduplicate modules, starting from npm3, pnpm that installs every module once, and yarn PnP that took a completely different approach. btw, qnm won't help you with The plot thickens as monorepos arrived to solve issues with developing multiple packages in the same repository. Package managers started to hoist dependencies to the root of the monorepo, which works in most cases, but since there are edge cases, you can still decide to no-hoist particular modules. Doing the optimizations mentioned above may bring issues (build-related / runtime-related). For example, relying on a plugin system where the plugin brought by the user or another library doesn't fit the version of the engine. Or having multiple versions of react on the same react tree. qnm was created to help debug these sorts of problems. With that in mind,
If you want to deduplicate TypeScript (which can lower your install time) you can do the following:
In case you want to forcefully verify you have only 1 version of TypeScript you can use either yarn resolutions or npm overrides But again, you probably have more productive things to do, so if install time is not a blocker for you, I would suggest dealing with this if it becomes problematic. |
Beta Was this translation helpful? Give feedback.
Hi @kristojorg!
The short answer is that you shouldn't worry about this, the long answer is a bit more complex.
One of the original goals of the node_module resolution algorithm was to enable multiple versions of the same module. This was (and probably still is) one of the biggest strengths of node. It enabled a library to declare its dependencies and always work correctly regardless of other dependencies that are installed in the same workspace.
The tradeoff of this approach is that you need to download a lot of different versions of the same module, and since the whole industry is built this way, you get a very heavy
node_modules
directory. It means that installing your dependencies (bo…