'Why is it considered bad to regenerate package lock file?

So I have a problem that package install gets stuck when running yarn install for my project. Removing yarn.lock and then running yarn install seems to resolve the issue. However, some people say that you should never delete the lock file because it might break the dependencies. Can someone explain how exactly does that work? And if I shouldn't regenerate or manually modify the lock file, what is the correct way to approach this kind of issues?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source