Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-merging package-lock.json

Tags:

git merge --no-ff account-creation 

Auto-merging package-lock.json CONFLICT (content): Merge conflict in package-lock.json Automatic merge failed; fix conflicts and then commit the result.

Any idea regarding this issue ?

like image 476
Ramana Avatar asked May 03 '18 16:05

Ramana


People also ask

Is package lock json auto generated?

package-lock. json is automatically generated for any operations where npm modifies either the node_modules tree, or package. json . It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.

Does package lock json update automatically?

package-lock. json is updated automatically on dependency changes. It should be committed to version control to ensure the same dependencies on install.

Should I remove package lock json?

package-lock. json defines versions used in my project. There should be no need to remove it completely and thus upgrade all dependencies to the latest version just because I upgrade Vaadin.


1 Answers

As per the docs:

Resolving lockfile conflicts

Occasionally, two separate npm install will create package locks that cause merge conflicts in source control systems. As of [email protected], these conflicts can be resolved by manually fixing any package.json conflicts, and then running npm install [--package-lock-only] again. npm will automatically resolve any conflicts for you and write a merged package lock that includes all the dependencies from both branches in a reasonable tree. If --package-lock-only is provided, it will do this without also modifying your local node_modules/.

To make this process seamless on git, consider installing npm-merge-driver, which will teach git how to do this itself without any user interaction. In short: $ npx npm-merge-driver install -g will let you do this, and even works with pre-[email protected] versions of npm 5, albeit a bit more noisily. Note that if package.json itself conflicts, you will have to resolve that by hand and run npm install manually, even with the merge driver.

like image 95
k0pernikus Avatar answered Sep 29 '22 17:09

k0pernikus