Comments (4)
A peer dependency range is only a suggestion. The most important thing about a peer dependency is that it should be a singleton. If there is a version of the package already installed in the workspace, pnpm will use it instead of installing something new. It is really easy to fix it, just install the version of the peer that you want as a direct dependency.
from pnpm.
Thanks for the super quick reply @zkochan!
A peer dependency range is only a suggestion. The most important thing about a peer dependency is that it should be a singleton.
Is this defined anywhere? I don't see any such notes in pnpm docs nor in how npm treats peerDeps — https://docs.npmjs.com/cli/v10/configuring-npm/package-json#peerdependencies
Also, in large monorepos, this is effectively impossible as some teams can choose to stay on certain versions of the dependency while other teams are free to upgrade. The e.g., here we have the build tool rollup wherein some teams depend on and use rollup@5 via 3rd party packages in the monorepo while some use rollup@4. An upgrade by one team should not break another teams code in such a scenario. And this btw works as expected in pnpm@8.
If there is a version of the package already installed in the workspace, pnpm will use it instead of installing something new.
What's weird is that even when pnpm@9 sees both versions of a peerDep, it chooses the latest one and seems to disregard whatever peerDep suggestion was provided by the package. This again worked as expected with pnpm@8.
Given that aligning versions of the peerDep is not currently possible in this large monorepo I speak of, what other alternatives do I have?
from pnpm.
Also, in large monorepos, this is effectively impossible as some teams can choose to stay on certain versions of the dependency while other teams are free to upgrade.
In that scenario you would need to install a different version of the peer dependency as a direct dependency for the subset of projects that use a different version of the peer dependency. Regardless of this issue, you would need to manually set a peer dependency for one of the groups.
from pnpm.
In that scenario you would need to install a different version of the peer dependency as a direct dependency for the subset of projects that use a different version of the peer dependency. Regardless of this issue, you would need to manually set a peer dependency for one of the groups.
Thank you for the workaround @zkochan!
Any reason why this works as expected in v8 and not in v9 btw?
from pnpm.
Related Issues (20)
- "pnpm why" doesn't work properly
- pnpm can create forbidden file name on windows HOT 1
- package peerDependencies are written into the lock file as if they were dependencies. HOT 1
- I cannot update version HOT 3
- `pnpm outdated` is suggesting an *older* version as the latest version
- Can't use pnpm global packages via SSH
- EBUSY: resource busy or locked and EPERM: operation not permitted on windows
- jsonwebtoken package is not compatible
- Missing dev dependencies (or executables) in Dockerfile HOT 1
- add npm "home" command
- The `--cwd` flag is unsupported but does not throw an error
- peerDependenciesMeta.optional ignored after new `pnpm install`
- `package_manager_strict = false` prints warning
- node-linker set to pnp and symlink set to false still generated node_modules
- Running install.sh without specifying pnpm version pulls 6.31.0 HOT 6
- Workspace packages peerDependencies don't work
- Install fails on OSX HOT 1
- Support `devEngines` field HOT 2
- `pnpm update -r --latest <package-name>` Updates all dependencies instead of only updating the one I selected, (MONOREPO) HOT 4
- `pnpm dedupe` is behaving nondeterministically HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pnpm.