Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 474
Alexander Panteleev Avatar asked Feb 12 '20 08:02

Alexander Panteleev


People also ask

Should I add yarn to Gitignore?

yarn/releases should not be in . gitignore . UPD: answer is outdated. Check Q&A section, mentioned above.

Does yarn need Git?

json file that provides information to Yarn about your package. Most packages use some kind of version control system. The most common one is git but Yarn doesn't mind whatever one you choose to use.

How do I clear my yarn cache?

If you want to remove a specific lib's cache run $ yarn cache dir to get the right yarn cache directory path for your OS, then $ cd to that directory and remove the folder with the name + version of the lib you want to cleanup.

What is Yarnrc?

Yarnrc files (named this way because they must be called . yarnrc. yml ) are the one place where you'll be able to configure Yarn's internal settings. While Yarn will automatically find them in the parent directories, they should usually be kept at the root of your project (often your repository).


1 Answers

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.

like image 113
Thomas Avatar answered Oct 26 '22 01:10

Thomas