npm

Merging lockfiles

npm writes package-lock.json files that lock the dependency hierarchy at installed versions. When merging changes that modify dependencies, these files can be very difficult to merge. If we're using Git, npm-merge-driver can do it for us using a merge driver.

Place the following into .git/config:

[merge "npm-merge-driver"]
        name = automatically merge npm lockfiles
        driver = npx npm-merge-driver merge %A %O %B %P

And this into .git/info/attributes:

npm-shrinkwrap.json merge=npm-merge-driver
package-lock.json merge=npm-merge-driver