ERESOLVE unable to resolve dependency tree
Tags: dependencies, npm, dependencytree, eresolve
Published: 2023-06-05 18:38:41

---
title: ERESOLVE unable to resolve dependency tree
published: true
date: 2023-06-05 16:26:14 UTC
tags: dependencies,npm,dependencytree,eresolve
canonical_url: https://medium.com/@seanhaddock_60973/eresolve-unable-to-resolve-dependency-tree-2df48e1345c4
---

![dogs chasing each other](https://cdn-images-1.medium.com/max/1024/0*BZpR4WCQEic1h0R8)
_Photo by Mark Galer on Unsplash_

In this post I wanted to walk through a recent experience I had trying to resolve an NPM dependency conflict. Really, I want to show you how to read the output that NPM gives you when it finds a dependency conflict, because it wasn’t that intuitive to me at first. Hopefully this will help you if you ever have to resolve dependency conflicts — and you probably will.

### Updating typescript

Trying to update typescript to the latest version, I received this output from NPM:

![npm output showing conflicting dependency](https://cdn-images-1.medium.com/max/659/1*KC35hsONSGXtWlOiDqvzCg.png)

Looking at this, it may not be obvious what the actual conflict is. But once you understand what’s going on here, it’s not hard to understand. Let’s break it down:

![](https://cdn-images-1.medium.com/max/832/1*hxJ56xpPQbqH2IVZMseVfg.png)

- Line 1 just indicates the name of your application (from package.json)
- Line 2 shows the version of typescript NPM found to install (5.1.3), based on the entry in package.json
- Line 4 lists the entry in dev dependencies that caused NPM to find 5.1.3 (typescript@^5.1.0). Note the “dev” in front, which indicates this is a _dev_ dependency.

![](https://cdn-images-1.medium.com/max/1024/1*vVAJ85WJjBFWGcGYx7Aokg.png)

This next block reveals what the problem is:

- Line 2 tells us that typescript@≥=4.9.3 < 5.1 is a peer dependency of @angular/compiler-cli@16.0.4, which is the wanted version of @angular/compiler-cli, based on package.json. A _peer_ dependency is a dependency that one of _your_ dependencies relies on. Since the peer dependency specifies a typescript version _less_ than 5.1, the _found_ typescript version 5.1.3 won’t work.

![](https://cdn-images-1.medium.com/max/1024/1*L9xeU3RK1NOp8eHnpYM3EA.png)

The rest of the output describes the dependency tree that got us here — _this_ is required by _that_ and _that_ is required by _this_, etc. It isn’t really important in this case, now that we know what the problem is. But let’s go over it anyway:

- Line 1 shows us that the dev dependency entry @angular/compiler-cli@^16.0.3 is what is causing @angular/compiler-cli@16.0.4 to be wanted (recall that @angular/compiler-cli has the peer dependency that is causing the problem)
- Line 2 informs us that @angular/compiler-cli@^16.0.0 is _also_ a peer dependency of the wanted @angular-devkit/build-angular@16.0.4 (so even if we _could_ remove @angular/compiler-cli as a dev dependency, it’s still required as a peer dependency by @angular-devkit/build-angular)
- Line 4 is saying the dev dependency entry @angular-devkit/build-angular@^16.0.3 is what is causing @angular-devkit/build-angular@16.0.4 to be wanted

Again, that last block didn’t help us this time. We know we want @angular/compiler-cli@16.0.4 and we now know that it’s not compatible with typescript@5.1.3 (according to its spec).

You can always force the issue, or use legacy-peer-deps, but you generally don’t want to do that unless you’re confident that NPM is just wrong — which happens. But in this case NPM seems to be correct — whether or not typescript@5.1.3 would actually break anything is a separate issue. I didn’t have my heart set on typescript 5.1+, so I complied and changed my typescript package.json entry to ~5.0.0 to resolve the conflict.

So this was just a quick look at how to read the output of an NPM dependency conflict error.