You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title: Yarn 4's strict dependency resolution prevents local package linking when peer dependencies differ
Description
When attempting to link a local package using either yarn link, the portal: protocol, or relative linking, Yarn 4 enforces strict peer dependency resolution that prevents linking when the linked package has different versions of shared dependencies. However, the same package works perfectly fine when installed directly from npm, suggesting this is a linking-specific issue rather than a fundamental dependency conflict.
Steps to Reproduce
Yarn 4 will fail with an error about conflicting dependencies:
Cannot link package-b into package-a dependency viem@npm:2.20.1 conflicts with parent dependency viem@npm:1.18.4
However, installing the same package from npm works without issues:
{
"dependencies": {
"package-b": "^1.4.0"// Works fine when installed from npm
}
}
Expected Behavior
The packages should link successfully, allowing for local development and testing, even with different versions of shared dependencies. The linked package should maintain its own dependency tree, just as it does when installed from npm.
Actual Behavior
Yarn 4 prevents the linking operation entirely, citing dependency conflicts, regardless of the linking method used. This is inconsistent with the behavior when installing the same package from npm, which works without issues.
Environment
Yarn version: 4.1.0
Node version: 18+
Operating system: Linux
Related Issues
This behavior seems to be a regression from Yarn 3, which allowed more flexible linking
Similar issues have been reported with workspace dependencies
To reproduce
Have two packages:
Package A (consumer) with dependency viem@^1.18.4
Package B (to be linked) with dependency viem@^2.20.1
Try to link Package B into Package A using any of these methods:
# Method 1: Using yarn linkcd package-b
yarn link
cd ../package-a
yarn link package-b
or
// Method 2: Using portal protocol in package.json
{
"dependencies": {
"package-b": "portal:../package-b"
}
}
or
// Method 3: Using relative path in package.json
{
"dependencies": {
"package-b": "file:../package-b"
}
}
This behavior makes local development more difficult, especially when working with packages that have different version requirements
The current workarounds (using --private or --ignore-engines flags) don't work
This is particularly problematic in monorepos or when developing packages that need to be tested with different dependency versions
All three common methods of local package linking (yarn link, portal protocol, and relative paths) are affected by this issue
The fact that the same package works when installed from npm but fails when linked locally suggests this is a linking-specific issue rather than a fundamental dependency conflict
The text was updated successfully, but these errors were encountered:
Self-service
Describe the bug
Title: Yarn 4's strict dependency resolution prevents local package linking when peer dependencies differ
Description
When attempting to link a local package using either
yarn link
, theportal:
protocol, or relative linking, Yarn 4 enforces strict peer dependency resolution that prevents linking when the linked package has different versions of shared dependencies. However, the same package works perfectly fine when installed directly from npm, suggesting this is a linking-specific issue rather than a fundamental dependency conflict.Steps to Reproduce
Yarn 4 will fail with an error about conflicting dependencies:
However, installing the same package from npm works without issues:
Expected Behavior
The packages should link successfully, allowing for local development and testing, even with different versions of shared dependencies. The linked package should maintain its own dependency tree, just as it does when installed from npm.
Actual Behavior
Yarn 4 prevents the linking operation entirely, citing dependency conflicts, regardless of the linking method used. This is inconsistent with the behavior when installing the same package from npm, which works without issues.
Environment
Related Issues
To reproduce
Have two packages:
viem@^1.18.4
viem@^2.20.1
Try to link Package B into Package A using any of these methods:
or
or
Environment
Additional context
Additional Context
--private
or--ignore-engines
flags) don't workThe text was updated successfully, but these errors were encountered: