删除`package-lock.json`以快速解决冲突 [英] Deleting `package-lock.json` to Resolve Conflicts quickly

查看:178
本文介绍了删除`package-lock.json`以快速解决冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常在团队设置中,我遇到了 package-lock.json 中的合并冲突,而我的快速解决方案一直是删除文件并使用 npm install .我没有认真考虑此修复程序的含义,因为它以前没有引起任何可察觉的问题.

In a team set up, usually, I have faced merge conflicts in package-lock.json and my quick fix has always been to delete the file and regenerate it with npm install. I have not seriously thought about the implication of this fix because it has not caused any perceivable problem before.

删除文件并以这种方式重新创建 npm 而不是手动解决冲突是否存在问题?

Is there a problem with deleting the file and having npm recreate it that way instead of resolving the conflicts manually?

推荐答案

是的,它可能会有不良的副作用,也许不是很常见,但是例如,您可以在package.json中找到"moduleX":" ^1.0.0" ,而您以前在 package-lock.json 中具有"moduleX":"1.0.0&" .

Yes 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.

通过删除 package-lock.json 并运行 npm install ,您可能会不知不觉地将其更新为moduleX的1.0.999版本,并且可能是他们创建了一个错误或进行了向后突破性的更改(不遵循语义版本控制).

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

无论如何,已经有一个标准的解决方案.

Anyway there is already a standard solution for it.

  1. 修复 package.json
  2. 中的冲突
  3. 运行: npm install --package-lock-only

https://docs.npmjs.com/cli/v7/configuring-npm/package-locks#resolving-lockfile-conflicts

这篇关于删除`package-lock.json`以快速解决冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆