C.W.K.
Stream
Lesson 05 of 05 · published

Yarn Wisdom

~9 min · yarn, wisdom, production

Level 0Newbie
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

Yarn Berry is the most opinionated package manager in this quest. These rules keep the opinions productive instead of obstructive.

Don't pick Berry casually. If your team is small, your tooling is changing fast, and you don't need monorepos or zero-installs, npm or pnpm are friendlier. Berry's wins compound on stable, large projects.

Decide on PnP up front. Either commit to PnP (set up your IDE SDKs, configure your bundlers, accept the friction) or set nodeLinker: node-modules from day one. Switching mid-project is painful.

If you adopt zero-installs, configure Git LFS. The .yarn/cache/ directory grows fast — Git's normal storage will balloon. Use Git LFS for .yarn/cache/**/*.zip to keep the repo cloneable.

Constraints are a maintenance superpower. The day you have a monorepo with three teams and every PR introduces a slightly different version of some shared dep, constraints save you. Set them up before that day, not after.

Don't use Yarn Classic for new projects. Maintenance-only means security patches only — no new features, no ecosystem investment. New projects: Berry.

Code

.gitattributes for zero-installs + Git LFS·text
# .gitattributes
.yarn/cache/**/*.zip filter=lfs diff=lfs merge=lfs -text

# Then enable LFS in the repo:
#   git lfs install
#   git lfs track ".yarn/cache/**/*.zip"
#   git add .gitattributes
#   git commit -m "chore: lfs for yarn cache"

External links

Exercise

If you're considering Berry for an existing project, list five tools your project depends on (bundler, IDE, type-checker, linter, test runner). For each, check if PnP is supported. If three or more aren't, plan to use 'nodeLinker: node-modules'. Better to know up front than to fight tooling later.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.