question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug?]: Incorrect linking result (unable to resolve peer dependency)

See original GitHub issue

Self-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:closed
  • Created a year ago
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
larixercommented, May 12, 2022

What about this proposal? It would easily fix --preserve-symlinks scenario and shouldn’t brake any current working code.

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.

1reaction
schusovskoycommented, May 6, 2022

Thanks! Now I understand the problem better than before. I’ll go figure it out and try

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found