-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override peer dependency not work #4214
Comments
I'm also experiencing an issue with pnpm.overrides. I'm trying to override pnpm to use a version of a package that's not vulnerable but it won't work. I add the override, run |
Also facing this issue. I've got a conflicting minor peer dependency and overriding it does not stop pnpm from erroring. |
I'm using pnpm version 7.25.0 and I have the same issue as @bestickley. |
I faced the same issue using version Here is minimal example:
Actual result: Expected result: |
I don't understand why it is needed to override peer dependencies. You can just install the versions of peer dependencies that you want as dependencies of your project. Even if Package extensions are also not needed. In OP's case they just had to run:
|
I use this feature to suppress warning. For example, |
So you just need to use the pnpm.peerDependencyRules.allowedVersions field: {
"pnpm": {
"peerDependencyRules": {
"allowedVersions": {
"vite": "4"
}
}
}
} |
@zkochan you are right. I reconfirmed and found I did use |
…ndency overrides work See pnpm/pnpm#4214 (comment)
@zkochan This is very counterintuitive. For a dependency used by 20+ workspace packages, I need to add the peer dependencies over 20 times. Things would be worse if exists many such peerdependencies |
I use // https://github.com/pnpm/pnpm/issues/4214
const peerDependencies = ['peerDependency1', 'peerDependency2'];
const { overrides } = rootPkg.pnpm;
function overridesPeerDependencies(pkg) {
if (pkg.peerDependencies) {
for (const dep of peerDependencies) {
if (dep in pkg.peerDependencies) {
pkg.peerDependencies[dep] = overrides[dep];
}
}
}
}
module.exports = {
hooks: {
readPackage(pkg, _context) {
// skipDeps(pkg);
overridesPeerDependencies(pkg);
return pkg;
},
},
}; |
"pnpm": {
"peerDependencyRules": {
"allowedVersions": {
"@ws/my-ws-pkg>aws-cdk-lib": ">=2.100.0"
}
}
},
Switching to this makes the error go away: "pnpm": {
"peerDependencyRules": {
"allowedVersions": {
"aws-cdk-lib": ">=2.100.0"
}
}
}, But the downside is too wide of an override. I only wanted to override for a single package. |
I don't like doing this because it doesn't signal intent. If somebody else evaluates dependencies, they will look at package.json and potentially find unused some unused dependency that I've installed in order to override a peerDep. Additionally, the dep I install might not be in the relevant range. Think about dead dependencies that no longer keep deps up-to-date and the range of one of their peerDeps only supports insecure versions of a package. In these scenarios, like trying to appease a security audit... what should one do? Additionally, does using a monorepo affect your answer? |
We have a large PNPM-based Bazel monorepo, and this drove us bonkers trying to resolve conflicting peer dependencies between different versions of packages we sometimes need to use. This gist, Overriding A Peer Dependency With PNPM shows you how we solve it. Thanks to @tjx666 and #4214 (comment), for getting us started. |
pnpm version:
6.25.1
Code to reproduce the issue:
package.json:
Some TypeScript file (some.ts):
Expected behavior:
some.ts successfully compilled.
Actual behavior:
Compilation error:
Additional information:
Error occured because there is in new
@pnp/odata
package new abstact methods.@pnp/sp-clientsvc
has@pnp/odata
aspeerDepedencies
with exact versions.Also another package and code use new version of
@pnp/odata
and@pnp/common
.Currently we are using Yarn, but we thinking about changing package manager. In Yarn we use
resolutions
property and it works as expected withpeerDependencies
.Currenty I found workaround with
"pnpm"."packageExtensions"
:Node.js: 14.18.2
OS: Windows
The text was updated successfully, but these errors were encountered: