Skip to content
Skills Library
Programming · Building & coding

yarn

/yarn

Expert Yarn package manager assistance covering Yarn Berry (v4+), Zero-Installs, PnP (Plug'n'Play), and workspaces. Use when managing fast, deterministic JavaScript monorepo dependencies.

Licence
MIT
Last repository change
01.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Expert Yarn package manager assistance covering Yarn Berry (v4+), Zero-Installs, PnP (Plug'n'Play), and workspaces. Use when managing fast, deterministic JavaScript monorepo dependencies.

Original author description

Expert Yarn package manager assistance covering Yarn Berry (v4+), Zero-Installs, PnP (Plug'n'Play), and workspaces. Use when managing fast, deterministic JavaScript monorepo dependencies.

How it works

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Original SKILL.md headings · 124 lines, 467 words
SKILL.md preview
---
name: yarn
description: Expert Yarn package manager assistance covering Yarn Berry (v4+), Zero-Installs, PnP (Plug'n'Play), and workspaces. Use when managing fast, deterministic JavaScript monorepo dependencies.
---

# Yarn

Yarn (Berry) is a modern package manager. It introduced Plug'n'Play (PnP) to eliminate `node_modules` and support **Zero Installs**.

## When to Use

- **Modern JavaScript Package Management (Yarn v4+)**: Fast, reliable dependency management with Corepack support.
- **Plug'n'Play (PnP) & Zero-Installs**: Eliminating `node_modules` folders for instant workspace switching and CI runs.
- **Enterprise Monorepos**: Coordinated workspace resolution, constraints, and release workflows.
- **Hardened Security & Integrity**: Strict lockfile checksums and automated dependency audits.

## Quick Start

```bash
corepack enable
yarn set version stable
yarn init -2

# Install
yarn add react
```

## Core Concepts

### Modern Yarn Configuration (.yarnrc.yml)

Configuring node-modules linker or Plug'n'Play:

```yaml
# .yarnrc.yml
nodeLinker: node-modules # Use 'pnp' for Zero-Installs, 'node-modules' for standard compatibility
compressionLevel: mixed
enableGlobalCache: true

packageExtensions:
  "@types/react@*":
    peerDependencies:
      react: "*"
```

### Workspace Commands in Monorepos

Executing commands across workspaces:

```bash
# Run build command in parallel across all workspaces
yarn workspaces foreach --parallel --verbose run build

# Run tests only on workspaces changed relative to main branch
yarn workspaces foreach --since=main run test

# Add dependency to a specific workspace
yarn workspace @my-org/web-app add swr
```

### Upgrading Dependencies with Interactive CLI

Upgrading packages adhering to SemVer:

```bash
# Interactively review and upgrade outdated packages
yarn upgrade-interactive

# Re-validate lockfile integrity
yarn install --immutable
```

## Common Patterns

### Yarn Berry Monorepo Workspaces with TypeScript Loose Mode

**Problem**: Slow installs and node_modules bloat across multiple internal monorepo packages.

**Solution**:
Configure Yarn Berry workspaces with `.yarnrc.yml`:

```yaml
# .yarnrc.yml
nodeLinker: node-modules # Use node-modules linker for maximum ecosystem compatibility
yarnPath: .yarn/releases/yarn-4.5.0.cjs

packageExtensions:
  "react-scripts@*":
    dependencies:
      "typescript": "*"
```

Root `package.json`:

```json
{
  "private": true,
  "workspaces": ["apps/*", "packages/*"]
}
```

## Best Practices

**Do**:

- Target modern Yarn (v4+) enabled through Corepack (`corepack enable yarn`).
- Use `yarn install --immutable` in CI/CD pipelines to prevent unintended lockfile updates.
- Leverage `yarn workspaces foreach` with `--since=main` to test only modified packages in monorepos.
- Use `packageExtensions` in `.yarnrc.yml` to cleanly resolve missing peer dependency warnings from older third-party packages.

**Don't**:

- Use legacy Yarn 1.x (Classic); migrate to modern Yarn v4+ for enhanced performance and security.
- Edit `yarn.lock` manually; resolve conflicts via `yarn install`.
- Mix npm or pnpm lockfiles within a Yarn repository.

## Troubleshooting

| Error                                                    | Cause                                                            | Solution                                                                |
| :------------------------------------------------------- | :--------------------------------------------------------------- | :---------------------------------------------------------------------- |
| `Usage Error: Couldn't find the node_modules state file` | Project running under PnP mode when tools expect `node_modules`. | Set `nodeLinker: node-modules` in `.yarnrc.yml` and run `yarn install`. |
| `YN0002: Missing peer dependency`                        | Package requires peer dependency not declared in consumer.       | Declare missing package in root `.yarnrc.yml` `packageExtensions`.      |
| `Yarn command not found`                                 | Yarn Berry binary missing in `.yarn/releases/`.                  | Run `corepack enable && corepack use yarn@stable`.                      |

## References

- [Yarn Documentation](https://yarnpkg.com/)

Versions

The database has no other skills named yarn.

Database snapshot: 13.11.2026 · package version 8f2ddaec437c (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95package-management
    Use when choosing or configuring JavaScript/TypeScript package managers, managing dependencies, setting up workspaces, or publishing packages. Covers npm, yarn, pnpm, and bun. USE FOR: package manager selection, npm/yarn/pnpm/bun configuration, monorepo workspaces, dependency…
  • 100rhdh-yarn-bump
    Bumps Yarn Berry across the RHDH repos — rhdh-plugins, rhdh midstream, rhdh-plugin-export-overlays, rhdh-cli, and GitLab CEE rhidp/rhdh and rhdh-plugin-catalog — with `yarn set version` plus install, and rewrites the pins Yarn cannot see: `packageManager`, `yarnPath`, `ENV…
  • 90monorepo-workspaces
    Run a JavaScript/TypeScript monorepo with workspaces, task orchestration, and internal package versioning that scales. Use when managing multiple packages in one repo or when a growing monorepo's builds and installs get slow.
  • 100bun-package-manager
    Use when managing dependencies with Bun's package manager. Covers installing packages, workspaces, lockfiles, and migrating from npm/yarn/pnpm to Bun.
  • 100npm
    Expert npm package manager assistance covering package.json, lockfiles, workspaces (monorepos), scripts, and security audits. Use when managing JavaScript/Node.js dependencies and publishing packages.
  • 100pnpm
    pnpm package manager. Fast, disk-efficient with excellent monorepo support. Use when managing dependencies or setting up monorepos. USE WHEN: user mentions "pnpm", "pnpm workspace", "pnpm-workspace.yaml", asks about "pnpm commands", "pnpm install", "workspace protocol" DO NOT…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.