Yarn lockfile is a generated one and it’s not recommended to fix any conflicts manually. Though Lockfile is generated based on your package.json, it acts as the source of truth for the versions of dependencies to be installed in your peers / collaborators machines.
At times, when you get conflicts, it’s hard to understand or resolve them manually or even automatically. Here is what you can do to solve this.
- Reset your lockfile to how it was when you took pull from your team’s repo
git checkout --theirs yarn.lock
- Modify your package.json file now
- Now run
yarn intall
to install and update the lockfile based on package modifications.
Previous (NOT Better approach / Wrong)
Lockfile is not the source of truth. Your’s package.json acts as the source for generating this lockfile. Follow these steps to fix the situation.
- Delete yarn lockfile
- Fix conflicts of package.json file
- Run yarn install to generate a fresh one. That’s it.