DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Boots
Boots

Posted on

Let Yarn Resolve Your Conflicts

Filing under: "How did I not know this?!?"


I am, generally speaking, conflict-averse.

But engineering, like life, guarantees the occasional conflict. And sometimes, this conflict occurs in the jungle that is your package manager's lock file.

To resolve a merge conflict in yarn.lock, I usually just delete it and run yarn again. This is the developer's equivalent of yelling "Tiny smoke bomb!" and running away.

Is this best practice? Probs not. Does it work? Pretty much always.

Well, today, I accidentally ran yarn before deleting my conflict-ridden yarn.lock.

To my delight, I got this message:

This is a thing! And I want the world to know it!!!

Yarn will try to resolve the merge conflicts in your lock file!

This feature was introduced with Yarn 1.0, it seems. Basically two years ago.

Sometimes it feels like I'm a little behind the times 😬

Top comments (5)

Collapse
 
nickytonline profile image
Nick Taylor • Edited on

There's so much to know these days. Better late than never! πŸ˜‰ For those using npm, it can do this as well. Simply run npm install --package-lock-only

Collapse
 
alexparra profile image
Alex Parra

I’ve ran into a few of these in the past...
My solution has been to use the frozen-lock-file flag cause in those situations I wasn’t adding a dependency just installing missing ones.
Will check this next time around.
Thanks for sharing!

Collapse
 
lizzieshipwreck profile image
Lizzie Shipton

You just changed my life. I feel like I wanna cry.

Collapse
 
brettimus profile image
Boots

let it all out! yarn is here for us 🧢😭

Collapse
 
lizzieshipwreck profile image
Lizzie Shipton

Also just wanted to update: ran it today and discovered that if the conflicts cannot be merged successfully, Yarn will simply regenerate a new one from scratch. So perhaps the old method isn't so wrong after all

18 Useful Github Repositories Every Developer Should Bookmark

>> Check out this classic DEV post <<