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
PNPM is incorrectly providing the same dependency version to multiple packages relying on different versions #5176
Comments
I can also see that the packages look correct in the node_modules. But when a command is run, it uses the incorrect package. For example I just added a basic test to package-1 and added a standard
When running |
Hey, I have a similiar problem. Running Running |
Looks like it is some issue with Jest, when hoisting is used. Add this
Run |
I'm unfortunately experiencing a similar problematic behaviour. I don't think this is an issue with just Jest and hoisting in particular given that this used to work properly before I upgraded to pnpm 7 (in version 6.32.8). Everything worked as expected before updating, the correct version of Jest was instanced in the expected workspace, but not anymore. One thing that I noticed is that (in version 7) this only happens after I run |
in v6 in I checked
the main diff I found is in this line |
@ConcernedHobbit does this help with the types issue #5176 (comment)? |
Looks like it works if I remove NODE_PATH from the command shim... And all tests seem to pass. But I am hesitant. It used to be required. |
I was mistaken. |
I highly recommend turning off |
Thanks for the comment. we were forced to use it because it is legacy. We cleared all the public-hoist-pattern today. 👍 |
If anyone else is hitting this we have a sort of workaround that doesn't require changing hoist patterns
This resolves to the right version of jest |
Sure, this helps with jest and type issues, but then there's problems with developing component libraries using peerDependencies for react, as then they aren't installed. This then requires configuring |
This would probably be the best fix, as I would expect |
Dang, (this is in the package which has
This might be a tsc issue, but I would still assume that it should work with pnpm out-of-the-box. |
|
@boiboif @ConcernedHobbit This issue cost us several days. But in our case it was not an issue with pnpm but with tsc and ts-jest. More specifically, in certain scenarios tsc traverses up your directory tree. Effectively ignoring whatever you declared in "typeRoots". To fix this we had to add "react" to "paths" in tsconfig.json. See: |
@zkochan Is there a reason |
I am trying to get PNPM to work with NX and this issue breaks distributed task execution. Since NX uses PNPM to run |
Instead of
The only downside is that some packages are published with require statements to other packages that are not added to their dependencies. These package will fail with hoist=false. You can selectively hoist the packages that appear in the errors or use package extensions to add the missing dependencies to the packages that use them. |
Have same problem on 7.27.0
|
The current workaround for this issue is to set |
I cannot reproduce the |
@zkochan This change suddenly broke all of our CI builds with GraphQL Codegen packages. Manually setting |
I have downgraded latest. Create a repo that reproduces the issue if you can. |
@zkochan Still trying to figure out if this change in PNPM maybe also just made a configuration mistake on our side apparent that just worked by accident so far. Will come back with results soon. |
Please never mind, found another thread. |
@zkochan Okay. Figured out that in my case it was never intended to work from the GraphQL Codegen side and just happened to work by accident in Yarn and PNPM until now. To cite from dotansimha/graphql-code-generator#3275 (comment):
We previously used a plugin in that config section which wasn't installed as a direct dependency. The change in PNPM here broke it now but that's probably fine. But from looking at the issue linked by @iobuhov there seem to be more tools which required sub-dependencies to be discoverable which this change apparently broke. |
I agree with @levrik that pnpm not "broke" things. It's just some weird config changes. I see that many packages that were built using node module resolution system, including beble for example, don't play nice with pnpm isolated system as they rely on default resolution strategy and because of that not always list their deps explicitly. |
Right, I was not expecting that the removal of NODE_PATH would break anything as the |
🚢 7.29.3 |
I have this in my package.json to work around a Jest issue with snapshots not working with prettier v3:
It seems that, when I do I guess I'll modify my package.json script to use the exact node_modules path to prettier and use that instead. I added this to my scripts section, seems to work:
|
pnpm version: 7.8.0
Code to reproduce the issue:
Attached is a very basic project with two packages, each relying on only a single devDependency (jest) - but each package has a different version of that same dependency. I have added a script
jest-version
which just logs the jest version for ease of use.pnpm-dependency-issue.zip
Package-1 - package.json:
Package-2 - package.json:
Expected behaviour:
I would expect when running
pnpm jest-version
in package-1 I would get an output of27.5.1
, and when runningpnpm jest-version
in package-2 I would get an output of24.8.0
.Actual behaviour:
I get an output of
24.8.0
for the command in both packages.Additional information:
node -v
prints: v16.16.0For what its worth, this does behave expected on npm (8.11.0).
The text was updated successfully, but these errors were encountered: