[Bug?]: Incorrect linking result (unable to resolve peer dependency)
See original GitHub issueSelf-service
- Iβd be willing to implement a fix
Describe the bug
Consider we have 3 workspaces in a project: service which depends on app which depends on lib. Yarn is configured to use node-modules linker. hoistingLimits for the service workspace is set to workspaces value. Also workspaces app and lib have βreactβ peer dependency and service depends on βreactβ.
After installation I expect to have node_modules structure capable to resolve βreactβ from all of the three workspaces. But in reality lib becomes unavailable to do this.
Below you can see expected and actual resulting structure.
Actual file tree
project
βββ node_modules
β βββ symlink to app
β βββ symlink to lib
βββ service
β βββ node_modules
β βββ symlink to app
β βββ react
βββ app
βββ lib
Expected file tree
project
βββ node_modules
β βββ symlink to app
β βββ symlink to lib
βββ service
β βββ node_modules
β βββ symlink to app
β βββ react
βββ app
β βββ node_modules
β βββ symlink to lib
βββ lib
To reproduce
https://github.com/schusovskoy/yarn-peer-repro
Environment
System:
OS: macOS 12.2.1
CPU: (8) x64 Apple M1 Pro
Binaries:
Node: 16.13.2 - /private/var/folders/td/01fyjv6d46x7gtvcn3dq78m40000gn/T/xfs-4662e098/node
Yarn: 3.2.0 - /private/var/folders/td/01fyjv6d46x7gtvcn3dq78m40000gn/T/xfs-4662e098/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:23 (12 by maintainers)
Top Results From Across the Web
Unable to resolve dependency tree error when installing npm ...
You have dependency conflict (incorrect and potentially broken dependency) as it says, so try to run the command with --force , or --legacy-peer...
Read more >could not resolve dependency peer react@ ^16.0.0 - You.com
Solution 1: Ignore the peerDependencies The easiest way to fix the issue is to pass an additional parameter βlegacy-peer-deps to npm install. The...
Read more >Understanding Peer Dependencies in JavaScript
Peer dependencies really come into play when you're developing code that will be used by others, such as plugins and packages. If you're...
Read more >How to solve peer dependencies error after updating ... - Reddit
I regularly update dependencies using npm i -g npm-check-updates & then doing ncu -u which updates my package.json with latest versions.
Read more >Error Codes | Yarn - Package Manager
The author of packageA can fix this problem by adding a peer dependency on packagePeer . If relevant, they can use optional peer...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well, you can try, I personally do not believe that this will fix
--preserve-symlinks
, maybe only this one case that you use, but what about other cases? Try and if E2E and integration tests will not fail, I will look at your code. Plus you need to add an integration test for the case that your code will fix.Thanks! Now I understand the problem better than before. Iβll go figure it out and try