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
overrides doesn't work as expected #4313
Comments
Seems the problem is overrides are handled in readPackage hook. When adding a new package, the manifest doesn't contain it and it will be treated as normal ('latest' in above case). Is this logic as expected? @zkochan cc @wre232114 |
I don't think the overrides should override direct dependencies at all. If you need to change a direct dependency, why do you need an override? Just change the direct dependency. Overrides are needed for subdependencies, where you can directly access the package.json files where they are declared. |
But I think this brings inconsistence, from the user's perspective, the overrides should unify all the version of the same package, no matter it is a direct dependencies or not. And in this issue, the first time we add a package it is latest(the overrides doesn't work), but if we do |
Firstly, I understand you point. But according to the purpose of this field:
I think it would be better to override the resolution for direct dependency. Also, currently the behavior doesn't strictly follow your point as i tested.
Anyway, I'm glad to contribute code. |
Yarn resolutions seem to work as you would like it to work. They override direct dependencies as well. So we can do what npm does. Or we can do what Yarn does. Vote with +1 for Yarn (overrides change direct dependencies) cc @pnpm/collaborators |
Looks like most support the Yarn way. I don't have objections in that case to make it work the same way as in Yarn. So to apply the overrides to direct dependencies as well. |
I have updated pnpm to v6.32 but it still is not overriding direct dependency. Maybe I am understanding wrong.
|
Make a repro repository because it works in my case. |
Thanks for the confirmation. I have tested. The override is successful when
but not
as suggested by |
Can confirm this happens to me as well. |
If you have issues related to overrides, open a new issue with steps to reproduce. A repository that reproduces the issue would be highly appreciated. |
pnpm version: 6.30.0
Code to reproduce the issue:
Just a package.json like this:
Then run
pnpm add lz-string
Expected behavior:
Updated package.json like this:
Actual behavior:
Overrides don't have effect when add a new direct dependency, and the package.json become:
After running
pnpm add lz-string
again, then it will be corrected.Additional information:
node -v
prints: 14.17.2The text was updated successfully, but these errors were encountered: