Skip to main content

How Yarn resolutions can save you

· One min read
Matej Jelluš
Tech leader and IT nerd who is constantly trying new things, sharing his experiences and still enjoys writing code in his free time. Currently looking for new challenges and opportunities.

Have you ever heard about yarn resolutions? It is not something you would use everyday, but it is definitely useful.

I had a problem

Yesterday I commited a piece of code, pushed it and after couple of minutes, the test env did not change. Problem was with jenkins build and a new package I added. That package is using a dependency with specific version which had known issue that caused problems from time to time. The issue was solved in a new version but package I used is using the old (buggy) version.

So I looked on GitHub and the package wasn't updated for a couple of months. This is a problem I wrote about in the past. Luckily this wasn't an error with the code, but with a dependency version defined in package.json.

Selective dependency resolutions

Yarn allowes you to override package versions inside your dependencies. So now it is easy to solve this kind of problem.

  "resolutions": {
"<package>/**/<dependency>": "<new version>"
}

This tells yarn, that the package is using its dependency with new version and not with the version defined in its package.json.

You can read more about it in the docs.


Do you like this post? Is it helpful? I am always learning and trying new technologies, processes and approaches. When I struggle with something and finally manage to solve it, I share my experience. If you want to support me, please use button below. If you have any questions or comments, please reach me via email juffalow@juffalow.com.

I am also available as a mentor if you need help with your architecture, engineering team or if you are looking for an experienced person to validate your thoughts.