'NPM: Link peer dependency to package alias

Assume I have legacy codebase working with some old packages:

"mobx": "5.15.4",
"mobx-react": "6.1.8",

While developing some new experimental feature, I wanna use newer versions of these packages, but also have to leave legacy in a working state. So, I'm aliasing newer versions of packages so I can use them alongside with the old ones:

"@new/mobx": "npm:mobx@^6.3.13"
"@new/mobx-react": "npm:mobx-react@^7.2.1"

But mobx-react using mobx as a peer dependency. Obviously, the problem is that @new/mobx-react is watching old mobx version and expectedly says that there should be mobx of version 6+.

Is there any way to manually resolve peer dependency of @new/mobx-react, so it will watch @new/mobx and not just mobx? Or, maybe there is a way to implicitly install peer deps for @new/mobx-react in a way it will not override old mobx version?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source