Sphere
Log in Join

pnpm 9 ERR_PNPM_PEER_DEP_ISSUES after upgrading from pnpm 8

I upgraded pnpm from 8.15.9 to 9.4.0 on a Monday morning and spent the rest of it reading peer dependency warnings.

The repo is a small pnpm workspace with three packages, Node 20.11.1, and an ESLint 9.2 setup that had just been migrated from the eslintrc format. Everything installed on pnpm 8. On pnpm 9 the install command exited nonzero:

$ pnpm install
Lockfile is up to date, resolution step is skipped
Packages: +1304
...
ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies

.
├─┬ eslint-plugin-react-hooks 4.6.0
│ └── ✕ unmet peer eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0: found 9.2.0
└─┬ @typescript-eslint/parser 7.11.0
└── ✕ unmet peer eslint@^8.56.0: found 9.2.0

## Reading the peer warning

pnpm 9 turned on strict-peer-dependencies by default. Under pnpm 8 it was off, so mismatched peers were printed as warnings and installs succeeded. Now they fail the build.

In this case the warnings were accurate. eslint-plugin-react-hooks 4.6.0 had not declared support for ESLint 9, and neither had that version of @typescript-eslint/parser. The plugin still worked in practice, but pnpm was right that we were relying on luck.

## The config that fixed it

The clean fix was upgrading the packages that had released ESLint 9 support: eslint-plugin-react-hooks 5.0.0 and @typescript-eslint 8.x. That removed most of the errors. One internal package still declared a stale peer range and had to be updated by hand.

For a transitional period I added an override in the root package.json:

json
{
"pnpm": {
"peerDependencyRules": {
"allowedVersions": {
"eslint": "9"
},
"ignoreMissing": ["@types/react"]
}
}
}

allowedVersions tells pnpm to accept 9.x for any peer that asks for a lower major. It is a blunt instrument, so keep it scoped to one dependency and delete it as soon as the packages catch up. ignoreMissing is for peers that are genuinely optional; it does not make a missing required peer go away.

## auto-install-peers and the other change

The second surprise was that pnpm 9 defaults auto-install-peers to true. On pnpm 8 we had it explicitly on, so nothing changed for us, but a few people on the team had it off locally and suddenly saw new packages in their lockfiles. If you need the old behaviour:

pnpm config set auto-install-peers false --location=project

Do not do that just to make the diff smaller. The lockfile change is the point.

Also worth knowing: pnpm 9 changed the default resolve-peers-from-workspace-root behaviour and the lockfile version jumped to 9.0, which means the first install rewrites the entire lockfile. Review that diff on its own, separately from any real dependency changes, or you will miss the actual updates in the noise.

There is a migration command, pnpm migrate, but I found it easier to read the pnpm 9 release notes for the two defaults above and change them deliberately. The failure message tells you the exact packages with bad peers, which is more than most package managers give you.

I still think pnpm is the best option for a workspace of this size. I just wish the major upgrade had been on a day when nothing else was on fire.