close

[solved] Deleting `package-lock.json` to Resolve Conflicts quickly

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Deleting package-lock.json to Resolve Conflicts quickly in nodejs. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How To Solve Deleting package-lock.json to Resolve Conflicts quickly Error ?

  1. How To Solve Deleting package-lock.json to Resolve Conflicts quickly Error ?

    To Solve Deleting package-lock.json to Resolve Conflicts quickly just install it globally npx npm-merge-driver install --global. You can read more about it here npm-merge-driver

  2. Deleting package-lock.json to Resolve Conflicts quickly

    To Solve Deleting package-lock.json to Resolve Conflicts quickly just install it globally npx npm-merge-driver install --global. You can read more about it here npm-merge-driver

Solution 1

it can have bad side effects, maybe not very often but for example, you can have in package.json "moduleX": "^1.0.0" and you used to have "moduleX": "1.0.0" in package-lock.json.

By deleting package-lock.json and running npm install you could be updated to version 1.0.999 of moduleX without knowing about it and maybe they have created a bug or done a backward breaking change (not following semantic versioning).

Anyway, there is already a standard solution for it.

  1. Fix the conflict inside package.json
  2. Run: npm install --package-lock-only

Solution 2

it can and will affect all the projects in a really bad way.

  1. if your team does not run npm install after each git pull you all are using different dependencies’ versions. So it ends with “but it works for me!!” and “I don’t understand why my code does not work for you”
  2. even if all the team runs npm install it still does not mean everything is ok. at some moment you may find your project acts differently. in a part that you have not been changing for years. and after (probably, quite painful) debugging you will find it’s because of 3rd level dependency has updated for next major version and this led some breaking changes.

Conclusion: don’t ever delete package-lock.json.

Yes, for first-level dependencies if we specify them without ranges (like "react": "16.12.0") we get the same versions each time we run npm install. But we cannot say the same about dependencies of 2+ level deep (dependencies that our dependencies are relying on), so package-lock.json is really important for stability.

In your case you better do the next way:

  1. fix conflicts in package.json
  2. run npm install

As easy as it looks. The same to yarn – it fixes lock file conflict on its own. The only requirement here is to resolve all the conflicts in package.json beforehand if any.

Solution 3

just install it globally npx npm-merge-driver install --global. You can read more about it here npm-merge-driver

Just want to warn people, who are interested in using the above package, that sometimes it can behave erratically and is difficult to remove. So although it is a useful tool, it still needs some work.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment