pnpm.io icon indicating copy to clipboard operation
pnpm.io copied to clipboard

docs: caveats of multiple package managers

Open jpbnetley opened this issue 10 months ago • 2 comments

I had an issue where pnpm was installed with corepack, but I would have a version mismatch when comparing the package manager in the package.json and the pnpm version in the terminal.

I created an issue with corepack: https://github.com/nodejs/corepack/issues/659

After some debugging, we determined that I had 2 versions of pnpm installed. One via corepack, and another via globally from npm.

See here as reference: https://github.com/nodejs/corepack/issues/659#issuecomment-2658982866

I was then suggested to maybe add documentation to warn against this odd behaviour here: https://github.com/nodejs/corepack/issues/659#issuecomment-2658993332

I am considering adding some information regarding this here: https://github.com/pnpm/pnpm.io/blob/main/docs/installation.md on line 97.

:::warning

Having multiple package manager versions installed can cause an incorrect version of a package manager being used, regardless of the version that is specified in the package.json.

To verify there are not multiple version installed, see this [corepack issue 659](https://github.com/nodejs/corepack/issues/659#issuecomment-2658982866).

:::

jpbnetley avatar Feb 14 '25 20:02 jpbnetley

You had pnpm v9 installed. With pnpm v10 you wouldn't have noticed any issue as it would switch to the right pnpm version automatically. So, I don't think a notice is needed.

zkochan avatar Feb 17 '25 00:02 zkochan

For me that is where the confusion came in. Because the package.json specified v10. And I happen to have a pnpm version installed with corepack and globally. It would always use v9, even though the package json specified v10. (as we discovered here: https://github.com/nodejs/corepack/issues/659#issuecomment-2658961475) For me, that was confusing.

I think in my case what caused this confusion is corepack could not install the new version after throwing a key id mismatch error. (see https://github.com/nodejs/corepack/issues/612 for more info) And one of the suggested fixes was to install pnpm globally: https://github.com/nodejs/corepack/issues/612#issuecomment-2631491212

Eventually I noticed the version miss match and didn't understand why the version specified in the package.json was not used.

But if you think the info is redundant, I can close the issue and docs pr. Let me know.

Thank you for taking the time to go through the issue :)

jpbnetley avatar Feb 17 '25 04:02 jpbnetley