Fix: NPM Dependency Hell

Error Message:

"ERESOLVE unable to resolve dependency tree" "peer dependency conflict" "Module not found: Error: Can't resolve..."

The Cause

Claude sometimes blindly runs npm install package-name without checking your existing package.json version constraints. It might install a React 19 library into a React 18 project, causing a cascade of peer dependency errors.

The Fix

1. The Nuclear Option (Clean Install)

This fixes 90% of issues. Tell Claude:

"Delete node_modules and package-lock.json, then run npm install from scratch to reset dependencies."

2. Force Resolution

If you know it's safe (e.g., legacy peer deps): Tell Claude:

"Run npm install --legacy-peer-deps to bypass the conflict."

3. Revert package.json

If Claude messed up your versions:

  1. Run git checkout package.json to revert to the last working state.
  2. Tell Claude: "You broke the build. I reverted package.json. Please try installing that package again, but check for version compatibility first."

Prevention

  • Explicit Instructions: When asking for a new library, say: "Install framer-motion, ensuring it is compatible with React 18."