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_modulesandpackage-lock.json, then runnpm installfrom 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-depsto bypass the conflict."
3. Revert package.json
If Claude messed up your versions:
- Run
git checkout package.jsonto revert to the last working state. - 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."
Share this article