Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ergusto/405dbbd4c9d27748db44e988c43f9996 to your computer and use it in GitHub Desktop.

Select an option

Save ergusto/405dbbd4c9d27748db44e988c43f9996 to your computer and use it in GitHub Desktop.
How to resolve package-lock.json conflicts

How to resolve package-lock.json conflicts

It is not possible to resolve conflicts of package-lock.json in GitHub and you need to do a manual merge.

  1. Update the main branch with the latest changes:
git checkout main
git pull
  1. Merge your feature branch into main:
git merge mybranch

You will see something like the following message:

Auto-merging package-lock.json
CONFLICT (content): Merge conflict in package-lock.json
Auto-merging package.json
CONFLICT (content): Merge conflict in package.json
Automatic merge failed; fix conflicts and then commit the result.
  1. Open VS code and:
  • Carefully resolve any conflict in package.json.
  • Ignore the conflicts in package-lock.json.
  1. Install packages, which will re-generate package-lock.json: npm install
  2. "Test drive" your application to make sure the conflicts in package.json have been resolved correctly: npm start
  3. If the application is starting (i.e. there are no missing dependencies), add all changes and finish the merge:
git add --update
git commit

(Make sure not to commit the *.orig files!)

  1. If everything looks fine, push to GitHub:
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment