[Feature] add more context to pnpm linker workspace peer dependency error
- [ ] I'd be willing to implement this feature (contributing guide)
- [X] This feature is important to have in this repository; a contrib plugin wouldn't do
Describe the user story
I am evaluating using yarn with the pnpm linker in a large repository, but I am getting the following error and it is unclear to me which packages are causing this problem.
The pnpm linker doesn't support providing different versions to workspaces' peer dependencies
My reading of this error is that it's telling me I have one package with a dependency on [email protected], and another package has a dependency on [email protected]. I'm not aware of any cases where we have this kind of divergence (we have other tooling that checks for this), so it would be helpful to know specifically where the issue is.
Describe the solution you'd like
The error should include which peer dependency is causing the problem.
Describe the drawbacks of your solution
It's possible that it would be difficult to include this information, or that there are too many conflicting versions to reasonably log out.
Describe alternatives you've considered
It's possible that this check could be done in an extension (or a constraint?), but the check/error is happening in yarn itself, so I think that is where the improvement should be made.
It'd be nice if the error message gave some idea of the state of the install as well. Did the install succeed? Succeed, but with incomplete / incorrect dependency resolution? Fail altogether?
I just switched a project that is working fine with nodeLinker: node-modules to nodeLinker: pnpm, and started getting various build errors. This was the first error I saw, and I had no context for ascertaining if this was the cause or some other issue.
In my case the installation succeeds?! However I think this is more of a defect. I am able to reproduce this issue even with one package in the monorepo.
I've created a minimal repro here, it requires:
- A "workspace" link to another package
- That other package needs to have any peer dependency
Interestingly, there's no case here where peer dependencies are unaligned. After peeking a bit at the source code and this comment, I'm starting to think that it's not saying that you do have different versions of peer dependencies, but rather that you should be advised that if you do, it won't work properly.
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Max
Binaries:
Node: 20.12.1 - /private/var/folders/hr/bf758kqx6f14sf0dyrw0v9zh0000gn/T/xfs-81d651d7/node
Yarn: 4.2.2 - /private/var/folders/hr/bf758kqx6f14sf0dyrw0v9zh0000gn/T/xfs-81d651d7/yarn
npm: 10.5.0 - ~/.nvm/versions/node/v20.12.1/bin/npm