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)
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
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!
You just changed my life. I feel like I wanna cry.
let it all out! yarn is here for us 🧶😭
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