debugbashnpmModeratepending
Debug: Git merge conflicts in package-lock.json or yarn.lock
Viewed 0 times
merge conflictpackage-lockyarn.locklock filenpm install
Error Messages
Problem
Merge conflicts in package-lock.json or yarn.lock are impossible to resolve manually due to file complexity.
Solution
Don't manually resolve lock file conflicts. Regenerate them:
Automate with git merge driver:
# For npm (package-lock.json)
# 1. Accept either version (doesn't matter which)
git checkout --theirs package-lock.json
# 2. Regenerate from merged package.json
npm install
# 3. Stage the regenerated lock file
git add package-lock.json
# 4. Continue merge
git merge --continue
# For yarn (yarn.lock)
git checkout --theirs yarn.lock
yarn install
git add yarn.lock
git merge --continue
# For pnpm (pnpm-lock.yaml)
git checkout --theirs pnpm-lock.yaml
pnpm install
git add pnpm-lock.yaml
git merge --continueAutomate with git merge driver:
# .gitattributes
package-lock.json merge=npm-merge
# .git/config or ~/.gitconfig
[merge "npm-merge"]
name = Regenerate package-lock.json
driver = npx npm-merge-driver merge %A %O %B %PWhy
Lock files are machine-generated and contain checksums, integrity hashes, and dependency trees that cannot be meaningfully merged by hand.
Context
Git merges or rebases involving dependency changes
Revisions (0)
No revisions yet.