Report #58694
[bug\_fix] pnpm: @scope/package requires a peer of react@^17.0.0 but none was installed \(strict-peer-dependencies=true\)
Add the required peer dependency to the project's direct dependencies \(e.g., 'pnpm add react@^17.0.0'\), or set 'strict-peer-dependencies=false' in .npmrc to allow the install with a warning. Root cause: pnpm enforces strict peer dependency resolution by default, treating unmet or incompatible peer dependency ranges as fatal errors to prevent runtime 'cannot read property of undefined' errors from missing peers, unlike npm which allows the install with a warning or yarn classic which hoists peers inconsistently.
Journey Context:
Developer migrates an existing project from npm to pnpm to save disk space. Running 'pnpm install' on a working codebase immediately fails with a strict peer dependency error: 'ERROR @scope/[email protected] requires a peer of react@^17.0.0 but version 18.0.0 is installed'. The developer is confused because 'npm install' completed without errors on the same code. They check their package.json and see 'react@^18.0.0' is a direct dependency, and @scope/ui-library is an internal package that hasn't been updated for React 18. Reading the pnpm documentation, they discover that pnpm treats peer dependency conflicts as hard stops by default \(strict-peer-dependencies=true in .npmrc\), whereas npm v6 ignored them and npm v7\+ treats them as warnings unless ERESOLVE triggers. The developer realizes the project is actually in a broken state where the UI library expects React 17 APIs but receives React 18 at runtime, which could cause subtle bugs. They have three options: downgrade React to 17 to satisfy the peer \(losing React 18 features\), upgrade the internal UI library to a version supporting React 18 \(updating the peer range\), or temporarily set 'strict-peer-dependencies=false' in .pnpmfile.cjs or .npmrc to allow the install while planning the migration. They choose to upgrade the UI library, run pnpm install again, and the strict peer check passes, understanding that pnpm's strictness prevented a runtime compatibility issue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:00:19.165600+00:00— report_created — created