It is not possible to resolve conflicts of package-lock.json in GitHub's merge tool and you need to do a manual merge.
- Update the
master
branch with the latest changes:git checkout master git pull
- Merge your feature branch into
master
:
You will see something like the following message:git merge mybranch
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.
- Open your editor (e.g. VSCode) and:
- Carefully resolve conflicts in
package.json
(if there is any) - Ignore the conflicts in
package-lock.json
- Carefully resolve conflicts in
- Install packages, which will re-generate
package-lock.json
:npm install
- "Test drive" your application to make sure the conflicts in
package.json
have been resolved correctly. - If the application is able to start up (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! - If everything looks fine, push to GitHub:
git push
But if your
package.json
looks something like this:and you are using
some-package
version1.2.0
, using this method, it may get bumped to any1.x.x
version, something like1.5.8
.Now, version
1.5.8
may introduce some problematic changes, which you don't want to add if you are not directly bumpingsome-package
.So the question is how to resolve
package-lock.json
conflicts, without changing version of any package that was not directly changed with the changes that let to the conflict?