I wonder who thought the way that `npm link` should work figured that no one would ever try to use local modules on their computer. I'm really incensed by the idea that modules that are the same version across multiple local dependencies are considered separate.
App A -> Lib A -> Lib B
-> Lib B
One would reasonably believe that if all of these modules are linked together via npm or yarn link that there would be one instance of each module. No.
App A has its own instance of Lib B, so if you were relying on a cache in Lib B it would not be shared, so there would be inconsistency.
In my case, I am using class transformer which caches a decorator. My application cannot see what a linked library's cache looks like, so the transformation is incomplete and causes an error! One of the single dumbest design decisions ever.
I've run into this issue with log4js library when it tries to do what log4j does with having global instance. I really had no understanding why it was occurring, but I knew it was due to `npm link` through trial and error, so I always resolved to publish my modules into an internal repo.
Fortunately, there is yalc to plug this hole. npm and yarn need to step up their game and make this right from the get go. I shouldn't need yarn workspaces or whatever. Microsoft Rush put all modules into one local modules folder and symlinked all the dependencies there, which is great.
npm and yarn should just create a .npm-module-cache in my user folder and that's that. Just like how Java does this. This is just for local development. Come on.
Update: After this post, I added `yalc` into my project manager CLI (inspired by Microsft Rush) to facilitate the linking.