← Back to Error Lab

npm ERR! code ERESOLVE: unable to resolve dependency tree

Published 2026-05-01

Educational use only. Content explains errors and defensive fixes for systems you own or are authorised to test. Do not use any technique here to access data, accounts, or networks without permission.

Root Cause

This error occurs when npm (v7 and above) encounters conflicting peer dependencies. A package you are installing requires a specific version of a peer dependency (like React 17), but another package or your root project requires a different, incompatible version (like React 18). npm halts the installation to prevent unpredictable behavior that could arise from using an unsupported version combination.

Fix / Solution

The safest approach is to update the offending packages so their peer dependency requirements align. If that's not possible, you can use the `--legacy-peer-deps` flag to force npm to ignore peer dependency conflicts (reverting to npm v6 behavior), or `--force` to resolve all conflicts by installing the latest versions. Be cautious with these flags as they may cause runtime errors.

Code Snippet

# ❌ Fails due to peer dependency conflict
npm install some-legacy-package

# ✅ Bypasses the strict check (use with caution)
npm install some-legacy-package --legacy-peer-deps