How do you resolve Git conflicts in yarn.lock

Question:

When multiple Git branches modify the dependencies in a project that uses Yarn, it is likely to introduce a conflict in the yarn.lock file. It is not a good idea to delete and regenerate the yarn.lock file because this will probably cause several packages to be unintentionally upgraded. What is the best way to quickly resolve conflicts in this file?

Answer:

Since Yarn 1.0 it’s easy because it has built in support for this scenario.

First solve the conflict in package.json manually, then just run this:

And then the conflict will be resolved and you can commit that or continue rebasing if that was what you were doing.

Leave a Reply