-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(posts): add "Fix npm error ERESOLVE could not resolve"
Post: 2024-10-24-fix-npm-error-eresolve-could-not-resolve.md
- Loading branch information
1 parent
8e1281a
commit 9355f44
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
_posts/2024/2024-10-24-fix-npm-error-eresolve-could-not-resolve.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
layout: post | ||
title: Fix npm error ERESOLVE could not resolve | ||
date: 2024-10-24 23:06:44 | ||
excerpt: How to fix npm error ERESOLVE could not resolve | ||
categories: npm | ||
--- | ||
|
||
This post goes over how to fix npm error `ERESOLVE could not resolve`. | ||
|
||
## Problem | ||
|
||
If there's an npm dependency conflict, `npm install` will throw an error: | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
``` | ||
npm error code ERESOLVE | ||
npm error ERESOLVE could not resolve | ||
npm error | ||
npm error While resolving: [email protected] | ||
npm error Found: [email protected] | ||
npm error node_modules/firebase | ||
npm error firebase@"11.0.1" from the root project | ||
npm error | ||
npm error Could not resolve dependency: | ||
npm error peer firebase@"^9.1.3 || ^10.0.0" from [email protected] | ||
npm error node_modules/firebaseui | ||
npm error firebaseui@"6.1.0" from the root project | ||
npm error | ||
npm error Conflicting peer dependency: [email protected] | ||
npm error node_modules/firebase | ||
npm error peer firebase@"^9.1.3 || ^10.0.0" from [email protected] | ||
npm error node_modules/firebaseui | ||
npm error firebaseui@"6.1.0" from the root project | ||
npm error | ||
npm error Fix the upstream dependency conflict, or retry | ||
npm error this command with --force or --legacy-peer-deps | ||
npm error to accept an incorrect (and potentially broken) dependency resolution. | ||
``` | ||
|
||
## Solution | ||
|
||
A temporary workaround is to install with `--force`: | ||
|
||
```sh | ||
npm install --force | ||
``` | ||
|
||
Or with `--legacy-peer-deps`: | ||
|
||
```sh | ||
npm install --legacy-peer-deps | ||
``` | ||
|
||
However, a better solution is to use [overrides](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides): | ||
|
||
```json | ||
{ | ||
"overrides": { | ||
"your-dependency": "1.0.0" | ||
} | ||
} | ||
``` | ||
|
||
For example, `firebaseui` depends on a different version of `firebase` so to specify it in overrides: | ||
|
||
```json | ||
{ | ||
"dependencies": { | ||
"firebase": "11.0.1", | ||
"firebaseui": "6.1.0" | ||
}, | ||
"overrides": { | ||
"firebase": "11.0.1" | ||
} | ||
} | ||
``` | ||
|
||
Alternatively, you can use the version from `dependencies`: | ||
|
||
```json | ||
{ | ||
"dependencies": { | ||
"firebase": "11.0.1", | ||
"firebaseui": "6.1.0" | ||
}, | ||
"overrides": { | ||
"firebase": "$firebase" | ||
} | ||
} | ||
``` |