Skip to content
Latchkey

npm ERESOLVE on @types/react - Fix Type Peer Conflicts in CI

A very common ERESOLVE case is not React itself but its type packages: a transitive library pins one @types/react major while your project resolves another, and npm cannot reconcile the two.

What this error means

npm install/npm ci aborts with ERESOLVE naming @types/react (or @types/react-dom), showing one package wanting types for React 18 while your tree has types for 17 or 19. The runtime React version is fine; only the type peers collide.

npm output
npm error code ERESOLVE
npm error Could not resolve dependency:
npm error peer @types/react@"^18.0.0" from @some/ui-types@2.0.0
npm error Conflicting peer dependency: @types/react@19.0.2
npm error   node_modules/@types/react

Common causes

Type packages drifted from the React major

A dependency pins @types/react to one major while your project (or another dep) brings in a different major, so npm has two incompatible type peers in one tree.

A stray @types/react in dependencies

Listing @types/react as a hard dependency at a different major than your React/react-dom types causes a conflict every clean install.

How to fix it

Align the type packages to the React major

Pin @types/react and @types/react-dom to the major that matches the React you run, then regenerate the lockfile.

Terminal
npm install -D @types/react@18 @types/react-dom@18
rm -f package-lock.json && npm install

Force one types version with overrides

  1. Add an overrides block pinning @types/react to one version for the whole tree.
  2. Verify the type-check still passes against that pinned major.
  3. Regenerate and commit the lockfile so CI installs the same tree.

How to prevent it

  • Keep @types/react(-dom) on the same major as react(-dom).
  • Use overrides to pin a single types version across the tree.
  • Commit the lockfile and install with npm ci.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →