Search code examples
reactjsnpmsemantic-versioningpnpm

PNPM installation does not update minor or patch versions even with caret (^)


PNPM seems to install exactly the version specified in package.json and doesn't seem that to install the latest minor version.

For example, In my package.json i have this dependency "@tanstack/react-query": "^4.13.5"

But while installing, pnpm gives this message @tanstack/react-query 4.13.5 (4.29.5 is available)

So my question is, why doesn't pnpm install 4.29.5 like npm does with the caret? And how do i achieve this?


Solution

  • to achieve this in pnpm, you must use resolution-mode=highest in your .npmrc file. while it doesn't exactly say in the docs (linked below) what highest does, it's pretty clear from what the other options are: time-based, and lowest-direct

    When resolution-mode is set to time-based, dependencies will be resolved the following way:

    Direct dependencies will be resolved to their lowest versions. So if there is foo@^1.1.0 in the dependencies, then 1.1.0 will be installed.

    Subdependencies will be resolved from versions that were published before the last direct dependency was published.

    When resolution-mode is set to lowest-direct, direct dependencies will be resolved to their lowest versions.

    more info: https://pnpm.io/npmrc#resolution-mode