'How do I set up package.json dependencies to work like peer Dependencies in version 7 of npm?
I have a package A that has 2 dependencies (aws-cdk-lib and constructs). I also have another package B with the same 2 dependencies. I also have package C which does not have the 2 dependencies.
I want to import package B into package A without installing the aws-cdk-lib and constructs, but when package C imports package B, I want it to install aws-cdk-lib and constructs.
I know this was possible using peer Dependencies in older versions of npm, but in newer versions, peer dependencies only gives you a warning if a dependency is not present.
Is there a way to set up package.json in package B so it will work in this way?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|