Search code examples
yarnpkg

Is it a good idea to delete yarn.lock and generate it again by running yarn install?


Recently I installed several npm packages, which I then have to remove. Now I'm not sure about the yarn.lock file and think it might have some legacy code inside it.

Is it a good idea to delete yarn.lock and generate it again by running yarn install?


Solution

  • Yarn.lock is a generated file yarn uses to know what versions of each dependency are installed so it can get those exact versions again when you run yarn install on a new machine. You don't need to delete it to remove the packages you aren't using any more from it, just remove them from package.json and run yarn upgrade and it will uninstall those packages and generate a new lock file without them