How to fix npm ERR! invalid: react@18.0.0, required peer react@^16.0.0 || ^17.0.0 in npm

npmINTERMEDIATELOWUpdated Dec 2, 2025ยท 124 views

You installed a peer outside the supported range. Install a compatible version or upgrade the plugin to one that supports your version.

Quick fix

Fixes npm ERR! invalid: react@18.0.0, required peer react@^16.0.0 || ^17.0.0

npm install react@"^16.0.0 || ^17.0.0"   # example range
  1. Install a version that satisfies the peer range
  2. Or upgrade the dependent package
  3. Reinstall to refresh lockfile
npm โ€” error
npm install react@"^16.0.0 || ^17.0.0" # example range
npm ERR! invalid: react@18.0.0, required peer react@^16.0.0 || ^17.0.0
shell
npm install react@"^16.0.0 || ^17.0.0"   # example range

What this error means

Peer dep invalid means the installed version does not satisfy the peer range declared by the dependent package, risking runtime incompatibility.

Typical symptoms

  • npm WARN peer dep invalid: <pkg>@<installed> requires <range>
  • Plugin fails at runtime due to API mismatch

Common causes

  1. Installing newer major of a peer than the plugin supports
  2. Lockfile drift after upgrades

How to fix "npm ERR! invalid: react@18.0.0, required peer react@^16.0.0 || ^17.0.0"

1Install a version that satisfies the peer range

Align the peer to the required range:

bash
npm install react@"^16.0.0 || ^17.0.0"   # example range
2Or upgrade the dependent package

Use a version of the plugin that supports your current peer:

bash
npm install package-name@latest
3Reinstall to refresh lockfile

After adjusting versions:

bash
rm -rf node_modules package-lock.json
npm install

Advanced notes

Keeping core libs and their plugins on the same major reduces peer-invalid churn. Overrides/--legacy-peer-deps can mask the warning but risk breakage.

Frequently asked questions

What does "npm ERR! invalid: react@18.0.0, required peer react@^16.0.0 || ^17.0.0" mean?
Peer dep invalid means the installed version does not satisfy the peer range declared by the dependent package, risking runtime incompatibility.
How do I fix "npm ERR! invalid: react@18.0.0, required peer react@^16.0.0 || ^17.0.0"?
You installed a peer outside the supported range. Install a compatible version or upgrade the plugin to one that supports your version.
What causes "npm ERR! invalid: react@18.0.0, required peer react@^16.0.0 || ^17.0.0"?
Installing newer major of a peer than the plugin supports Lockfile drift after upgrades
Is the "npm ERR! invalid: react@18.0.0, required peer react@^16.0.0 || ^17.0.0" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading