npm ERR! peer dep missing
This error matches known, documented patterns with reliable solutions.
Quick Fix (Most Common Solution)
- Install the missing peer dependency manually
- Use --legacy-peer-deps flag
Seeing "npm ERR! peer dep missing"? This error can be frustrating, but it's usually fixable. It typically affects your development workflow or system. Below you'll find clear, step-by-step solutions to resolve this issue.
What This Error Means
A package requires another package to be installed alongside it.
Frequently documented in developer and vendor support forums.
Not affiliated with browser, OS, or device manufacturers.
New here? Learn why exact error messages matter →
Common Causes
- Peer dependency not in package.json
- Version mismatch with peer
- npm 7+ strict peer dependency checking
How to Fix
- Install the missing peer dependency manually
- Use --legacy-peer-deps flag
- Update packages to compatible versions
Last reviewed: March 2026 How we review solutions
Why This Happens
npm emits peer dependency warnings (npm 7+) or errors when a package declares a peerDependency that is not installed at the required version. Peer dependencies are a declaration by a package that it needs a specific library to be provided by the consuming project, rather than installing its own copy. This pattern is used by plugins, extensions, and frameworks: React component libraries declare react as a peer dependency because they need to use the same React instance as your application (having two copies of React causes subtle bugs with hooks and context). When you install a package with unmet peer dependencies, npm 7+ warns by default and npm 8+ can error depending on configuration. The most common cause is version mismatches: your project has React 17 but a component library requires React 18 as a peer. The second most common cause is missing top-level installations: you installed a plugin (e.g., eslint-plugin-react) but never installed its peer dependency (eslint) explicitly. npm 6 and earlier automatically installed peer dependencies, but npm 7+ changed this to require explicit installation, causing many existing projects to see these warnings for the first time after upgrading npm.
Quick Diagnostic Checklist
- Read the warning to see which peer dependency is missing and what version is needed
- Install the missing peer dependency: npm install peer-package@required-version
- Check for version conflicts: npm ls peer-package
- If peer versions conflict, check if the package supports your version
- Use --legacy-peer-deps to install without resolving peers (temporary workaround)
Resolving missing and conflicting peer dependencies
# Warning output:
# npm WARN ERESOLVE overriding peer dependency
# npm WARN While resolving: eslint-plugin-react@7.33.0
# npm WARN Found: eslint@9.0.0
# npm WARN node_modules/eslint
# npm WARN eslint@"^9.0.0" from the root project
# npm WARN peer eslint@"^7.0.0 || ^8.0.0" from eslint-plugin-react@7.33.0
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Plugin needs ESLint 7 or 8
# Step 1: See what's installed vs what's needed
$ npm ls eslint
# project@1.0.0
# ├── eslint@9.0.0 <-- Installed
# └─┬ eslint-plugin-react@7.33.0
# └── UNMET PEER DEPENDENCY eslint@"^7.0.0 || ^8.0.0" <-- Needs 7 or 8
# Step 2: Option A — Downgrade to a compatible version
$ npm install eslint@8
# Step 3: Option B — Upgrade the plugin to support ESLint 9
$ npm install eslint-plugin-react@latest
# Check if latest version supports ESLint 9
# Step 4: Option C — Force install (may cause runtime issues)
$ npm install --legacy-peer-deps
# Ignores all peer dependency conflicts
# Step 5: For missing (not conflicting) peer deps
# npm WARN react-dom@18.3.1 requires a peer of react@^18.3.1
$ npm install react@^18.3.1 # Simply install the missing peer
Edge Cases & Unusual Scenarios
Multiple packages requiring different peer versions
If package A needs react@^17 and package B needs react@^18, you cannot satisfy both. Check if package A has an updated version supporting React 18. If not, you may need to replace one of the packages with an alternative that supports your React version.
npm 6 to npm 7+ migration
npm 6 auto-installed peer dependencies. npm 7+ does not. When upgrading npm, existing projects suddenly show peer dependency warnings. Run npm install to let npm 7+ attempt to resolve peers, or add missing peers manually.
Monorepo with shared peer dependencies
In npm workspaces, peer dependencies should be installed in the root package.json so all workspace packages share the same instance. If a peer is installed in a workspace package instead of the root, other packages may not see it.
Optional follow-up
Some users ask whether saving fixes for recurring errors would be useful when the same issue appears again.
Was this explanation helpful?
Frequently Asked Questions
What is a peer dependency?
A package that must be installed by the consumer rather than automatically.
Why did this work before?
npm 7+ enforces peer dependencies more strictly than earlier versions.
What does --legacy-peer-deps do?
It tells npm to ignore peer dependency conflicts and install packages the way npm 6 did. This is a temporary workaround—packages may not work correctly if their peer requirements are unmet. Use it only when you cannot resolve the conflict through version changes.
Why do packages use peer dependencies instead of regular dependencies?
Peer dependencies ensure all code uses the same instance of a shared library. If a React component library bundled its own copy of React, your app would have two React instances, causing hooks, context, and state to break. Peer dependencies force a single shared copy.
How do I find which version of a peer dependency to install?
Check the package documentation or run npm view package-name peerDependencies. This shows the exact version ranges the package expects. Install a version that satisfies all peer requirements from all your dependencies.
Related Resources
Also Known As
- npm install error
- npm dependency error
- node package manager error
- npm ERR! message
Common Search Variations
- "npm install not working"
- "npm ERR how to fix"
- "node modules error fix"
- "npm install failed what to do"
- "npm dependency conflict solution"
- "why does npm install fail"
Related Errors
Still Stuck?
Paste a different error message or upload a screenshot to get help instantly.