Search code examples
gityarnpkggitignoreyarnpkg-v2

Yarn v2 gitignore


I upgraded yarn from v1.22.0 to v2.0.0-rc.29. It generated .yarn folder with:

  • folders: cache, releases, unplugged
  • files: build-state.yml

Should I add whole .yarn folder to .gitignore? Or maybe some nested folders in there like .yarn/cache?

Also, what to do with .pnp.js. Do I commit it, or add to .gitignore


Solution

  • See the Questions & Answers section of the documentation. It has changed several times, so for the most up to date answer just click that link!

    But in the StackOverflow spirit of "no link-only answers" here's a snapshot:

    Which files should be gitignored?

    If you're using Zero-Installs:

    .yarn/*
    !.yarn/cache
    !.yarn/patches
    !.yarn/plugins
    !.yarn/releases
    !.yarn/sdks
    !.yarn/versions
    

    If you're not using Zero-Installs:

    .pnp.*
    .yarn/*
    !.yarn/patches
    !.yarn/plugins
    !.yarn/releases
    !.yarn/sdks
    !.yarn/versions
    

    Note that, of the paths you mention, only .yarn/releases should not be in .gitignore.