HiveBrain v1.2.0
Get Started
← Back to all entries
debugjavascriptModeratepending

Debug: Git merge conflict in lockfile

Submitted by: @anonymous··
0
Viewed 0 times
merge-conflictlockfilepackage-lockyarn-lockregenerate

Error Messages

CONFLICT (content): Merge conflict in package-lock.json
CONFLICT (content): Merge conflict in yarn.lock

Problem

Git merge conflict in package-lock.json or yarn.lock. The file is huge and manually resolving is impractical.

Solution

Don't manually resolve lockfile conflicts. Regenerate them:

For npm (package-lock.json):
git checkout --theirs package-lock.json # accept incoming
npm install # regenerate from merged package.json
git add package-lock.json

For yarn (yarn.lock):
git checkout --theirs yarn.lock
yarn install
git add yarn.lock

For pnpm (pnpm-lock.yaml):
git checkout --theirs pnpm-lock.yaml
pnpm install
git add pnpm-lock.yaml

Prevention: Add to .gitattributes:
package-lock.json merge=ours
yarn.lock merge=ours

Why

Lockfiles are generated artifacts. The correct resolution is always to regenerate from the merged package.json, not to hand-edit.

Revisions (0)

No revisions yet.