I have a parent workspace A that has a dependency on a child workspace B. I am using PnP.
If I run yarn install in A's directory, the file .pnp.cjs is created. That's expected because I need to ensure that when packages A and B depend on a third-party package like graphql-js, only a single instance of graphql-js is loaded when A runs, or else this happens.
However, maybe I have unit tests or some yarn script I want to run directly inside project B. When I try to run the script, it complains: Usage Error: The project in B/package.json doesn't seem to have been installed - running an install there might help. OK, fine, so I run yarn install in B's directory, which creates a .pnp.cjs file in the directory. Then I try to run the tests/script again in B:
Error: Unable to locate pnpapi, the module 'B/[file]' is controlled by multiple pnpapi instances.
This is usually caused by using the global cache (enableGlobalCache: true)
Controlled by:
B/.pnp.cjs
A/.pnp.cjs
How is it possible to run unit tests or scripts in B, which requires B to have its own .pnp.cjs file, and still have dependencies controlled by A to avoid multiple instances of 3rd-party packages when A runs?