Verify latest release
pnpm version
12.4.1
Which area(s) of pnpm are affected? (leave empty if unsure)
Dependencies resolver
Link to the code that reproduces this issue or a replay of the bug
No response
Reproduction steps
-
Run pn init to create the package.json
-
Create a pnpm-workspace.yaml in the project root with:
catalogMode: prefer # or strict
catalog:
tailwindcss: ^4.3.3
-
Run:
-
Observe the warning/error and what gets written to package.json.
Describe the Bug
When a package is already defined in the default catalog and its catalog range covers the version pn add wants to install, pn add <pkg> (without an explicit version) does not use the catalog. Instead it warns and writes a direct version range:
[WARN] Catalog version mismatch for "tailwindcss": using direct version "^4.3.3" instead of catalog version "^4.3.3".
devDependencies:
+ tailwindcss 4.3.3
package.json after the command:
{
"devDependencies": {
"tailwindcss": "^4.3.3"
}
}
With catalogMode: strict the same command fails outright:
Error: ERR_PNPM_CATALOG_VERSION_MISMATCH
× adding a new package
╰─▶ Wanted dependency outside the version range defined in catalog
Note the two specifiers in the warning are identical (^4.3.3 vs ^4.3.3), so there is no real mismatch — the catalog does cover the wanted version and the dependency should resolve through the catalog.
Passing an explicit exact version works as expected:
pn add -D tailwindcss@4.3.3 # -> "tailwindcss": "catalog:" ✅
Regression
This works in v11 and regressed in v12:
| pnpm version |
pn add tailwindcss result |
| 11.27.0 |
"tailwindcss": "catalog:", no warning/error |
| 12.0.0 |
"tailwindcss": "^4.3.3" + warning/error |
| 12.1.0 |
"tailwindcss": "^4.3.3" + warning/error |
| 12.2.1 |
"tailwindcss": "^4.3.3" + warning/error |
| 12.3.4 |
"tailwindcss": "^4.3.3" + warning/error |
| 12.4.1 |
"tailwindcss": "^4.3.3" + warning/error |
This is related to but distinct from #13715 (catalogMode: strict rejecting pn update <pkg>@<version> against a range-pinned entry), which fixed the case where an exact version is supplied. The plain pn add <pkg> case (a wanted range) is still not covered.
Expected Behavior
When the default catalog defines tailwindcss: ^4.3.3:
pn add -D tailwindcss should add "tailwindcss": "catalog:" to package.json (the catalog range covers the wanted range), with no warning.
catalogMode: strict should not throw ERR_PNPM_CATALOG_VERSION_MISMATCH, because the wanted version is inside the catalog's range.
catalogMode: prefer should fall back to a direct version only when the catalog genuinely cannot satisfy the wanted version.
- Behavior should match v11 (11.27.0), which already does the right thing.
Which Node.js version are you using?
24.19
Which operating systems have you used?
If your OS is a Linux based, which one it is? (Include the version if relevant)
7.2.3-1-cachyos
Verify latest release
pnpm version
12.4.1
Which area(s) of pnpm are affected? (leave empty if unsure)
Dependencies resolver
Link to the code that reproduces this issue or a replay of the bug
No response
Reproduction steps
Run
pn initto create thepackage.jsonCreate a
pnpm-workspace.yamlin the project root with:Run:
Observe the warning/error and what gets written to
package.json.Describe the Bug
When a package is already defined in the default catalog and its catalog range covers the version
pn addwants to install,pn add <pkg>(without an explicit version) does not use the catalog. Instead it warns and writes a direct version range:package.jsonafter the command:{ "devDependencies": { "tailwindcss": "^4.3.3" } }With
catalogMode: strictthe same command fails outright:Note the two specifiers in the warning are identical (
^4.3.3vs^4.3.3), so there is no real mismatch — the catalog does cover the wanted version and the dependency should resolve through the catalog.Passing an explicit exact version works as expected:
pn add -D tailwindcss@4.3.3 # -> "tailwindcss": "catalog:" ✅Regression
This works in v11 and regressed in v12:
pn add tailwindcssresult"tailwindcss": "catalog:", no warning/error"tailwindcss": "^4.3.3"+ warning/error"tailwindcss": "^4.3.3"+ warning/error"tailwindcss": "^4.3.3"+ warning/error"tailwindcss": "^4.3.3"+ warning/error"tailwindcss": "^4.3.3"+ warning/errorThis is related to but distinct from #13715 (
catalogMode: strictrejectingpn update <pkg>@<version>against a range-pinned entry), which fixed the case where an exact version is supplied. The plainpn add <pkg>case (a wanted range) is still not covered.Expected Behavior
When the default catalog defines
tailwindcss: ^4.3.3:pn add -D tailwindcssshould add"tailwindcss": "catalog:"topackage.json(the catalog range covers the wanted range), with no warning.catalogMode: strictshould not throwERR_PNPM_CATALOG_VERSION_MISMATCH, because the wanted version is inside the catalog's range.catalogMode: prefershould fall back to a direct version only when the catalog genuinely cannot satisfy the wanted version.Which Node.js version are you using?
24.19
Which operating systems have you used?
If your OS is a Linux based, which one it is? (Include the version if relevant)
7.2.3-1-cachyos