Aligning Dependencies After Lock File Conflicts
Compare package.json files from different branches to resolve dependency version conflicts that cause lock file merge issues.
Dependency Management
Detailed Explanation
Resolving Lock File Dependency Conflicts
Lock file conflicts are one of the most common merge conflicts in JavaScript projects. They happen when two branches modify package.json differently. The Package.json Diff tool helps you understand the underlying dependency changes that caused the conflict.
Typical conflict scenario
Branch A (feature-auth):
dependencies:
+ jsonwebtoken: ^9.0.2
~ axios: ^1.5.0 -> ^1.6.0
Branch B (feature-api):
dependencies:
+ @prisma/client: ^5.7.0
~ axios: ^1.5.0 -> ^1.6.2
Resolution workflow
- Compare main branch package.json with branch A to see branch A's changes
- Compare main branch package.json with branch B to see branch B's changes
- Identify overlapping changes (both modified axios, but to different versions)
- Create the merged package.json with the higher version of shared changes
- Verify the final result by comparing against main
Using the diff tool for each step
For each comparison:
- Paste the base (main) package.json in the left panel
- Paste the branch package.json in the right panel
- Filter to Changed only and Added only to see just the modifications
- Note overlapping changes for manual resolution
Preventing future conflicts
| Strategy | How |
|---|---|
| Renovate/Dependabot auto-merge | Keep dependencies updated continuously |
| Branch from latest main | Reduce drift between branches |
| Separate dependency PRs | Don't mix feature changes with dependency updates |
| Use version ranges | Allow lock file to resolve minor/patch automatically |
Use Case
Two developers have been working on separate feature branches that both updated dependencies. When merging, the lock file has massive conflicts. They use Package.json Diff to compare each branch's package.json against main to understand what each branch changed.