Search code examples
npmnpm-installyarnpkg

Why does my project have both a package-lock.json and yarn.lock file?


I am working on a React project.

I have only used npm within the project. I am not sure how the yarn.lock file was generated initially. Is it okay to delete yarn.lock since I am not using yarn?

When I run npm install <package> to install packages, yarn.lock is updated but package-lock.json remains unchanged, why is that?

Do I need both a package-lock.json and yarn.lock file?


Solution

  • Usually, when you use npm, you will see a package.json and a package-lock.json files.

    When you use yarn, you will see a package.json and a yarn.lock files.

    I suggest to push your functional project to git first, then clone the project to a new repository with the same content and do some tests:

    1. delete node_modules, yarn.lock and package-lock.json
    2. npm install

    You shouldn't see a yarn.lock anymore.