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

别等时光非礼了梦想. 提交于 2019-12-02 23:42:46

Yes, it can and will affect all the project in 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. in your case you better do next way:

Approach 1

  1. revert your changes in package-lock.json
  2. stash your changes
  3. pull most recent code version
  4. run npm install for all the dependencies you need to be added
  5. unstash your changes

Approach 2

  1. run merging
  2. for coflict resolution choose "their changes only" strategy on package-lock.json
  3. run npm install so dependencies you want to add are also included into package-lock.json
  4. finish with committing merge commit

I know it's an old question but for future seekers, you can also use npm-merge-driver which try to automatically resolve the npm related files' merge issues.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!