Gitflow
🔒package-lock.json ConflictMedium+500 XP
Workshop
Scenario reference

package-lock.json Conflict: the situation, step by step

The situation

Both your branch and main bumped dependencies. The merge says `package-lock.json` is in conflict — 800 lines of unreadable diff.

Never hand-edit lockfiles. Take one side, then regenerate.

Medium · 4 steps · +500 XP

What you will practice

This scenario walks through 4 steps, in order:

  1. 01Try the merge to see the conflict
  2. 02Take main's lockfile wholesale
  3. 03Stage and commit (then re-run npm install offline)
  4. 04Finalize the merge
Reveal the step-by-step commands

Try the terminal first — you learn more by doing. When you want to check yourself, here is the command for each step.

  1. 1. Try the merge to see the conflict
    git merge main
  2. 2. Take main's lockfile wholesale
    git checkout --theirs package-lock.json
  3. 3. Stage and commit (then re-run npm install offline)
    git add package-lock.json
  4. 4. Finalize the merge
    git commit -m "merge: regenerate lockfile"

Key takeaway

Take theirs, run `npm install`, commit. Lockfile = derived artifact.