npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Dealing with package-lock.json conflicts?

How do I handle the awful package-lock.json conflicts when I merge branches or pull?


package-lock.json conflicts are super easy to resolve! Just run this command:

$ npx npm-merge-driver install -g

and conflicts will be resolved automatically across all your npm projects. In the vast majority of cases, you won’t even notice the conflict being resolved, except your “applying patches” phase during rebases will take a little longer because it’s running npm under the hood. In the future, we expect to include this merge driver directly with npm itself, but for now, it’s an external tool.

There’s a single caveat: If you also get a conflict in package.json or other files when merging, the merge-driver will fail and you need to do an npm install --package-lock-only with a recent version of npm (npm@>=5.7.0) in order to have it resolve the conflicts for you.