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?
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:
$ yarn install
yarn install v1.0.1
info Merge conflict detected in yarn.lock and successfully merged.
[1/4] Resolving packages...
And then the conflict will be resolved and you can commit that or continue rebasing if that was what you were doing.
A good approach is detailed in this github discussion about the issue.
git rebase origin/masterWhen the first conflict arises, I checkout the
yarn.lockthen re-perform the installationgit checkout origin/master -- yarn.lock yarn installThis generates a new
yarn.lockbased on the origin/master version of yarn.lock, but including the changes I made to mypackage.json. Then it's just a matter of:git add yarn.lock git rebase --continue
this file is too long so if you need to check conflict in vscode without terminal maybe you can try a search in this file for terms like: >>>>>>>, =======, <<<<<<< or HEAD