Skip to content

/compare/yarn/yarn-classic-vs-yarn-berry

Yarn 1 (Classic) vs Yarn 4 (Berry): differences and command mapping

The commands on this page have not been executed by our verification runner yet.updated
tool
Yarn
compares
Yarn 1 (Classic) vs Yarn 2+ (Berry, today Yarn 4)

Yarn 1 (Classic, 1.22.x) only receives critical fixes; new features land in Yarn 2 and later, the codebase called Berry (current major: Yarn 4). Berry is installed per project and pinned with the packageManager field (Corepack), is configured in .yarnrc.yml, can install without node_modules (Plug'n'Play) and renames several commands. Both read package.json the same way, so most projects migrate by running yarn set version stable and yarn install.

Side by side

CriterionYarn 1 (Classic)Yarn 2+ (Berry)
InstallationGlobal: npm install -g yarnPer project: corepack enable, then yarn set version stable (writes packageManager)
node_modulesAlways, hoisted like npmnodeLinker: pnp (no node_modules), node-modules or pnpm
Config file.yarnrc and .npmrc.yarnrc.yml only (npmRegistryServer, npmAuthToken...)
Lockfileyarn.lock (v1 format)yarn.lock with __metadata (YAML), not readable by Yarn 1
CI installyarn install --frozen-lockfileyarn install --immutable (default when CI is detected)
Messageserror / warning / infoCoded messages (YN0000...)
Run a package oncenpxyarn dlx PACKAGE
Pluginsnoneyarn plugin import; many features are plugins
MaintenanceCritical fixes onlyActive development

Command mapping

Yarn 1Yarn 2+
yarn install --frozen-lockfileyarn install --immutable
yarn upgrade PACKAGEyarn up PACKAGE
yarn upgrade-interactiveyarn upgrade-interactive (built in since Yarn 4)
yarn install --productionyarn workspaces focus --production
yarn global add PACKAGEremoved: use yarn dlx PACKAGE or a project dependency
yarn create APPyarn create APP (runs through yarn dlx)
yarn workspaces run buildyarn workspaces foreach -A run build
yarn why PACKAGEyarn why PACKAGE

Migrating a project

bash
corepack enable
yarn set version stable          # downloads Yarn 4 and writes packageManager to package.json
echo "nodeLinker: node-modules" >> .yarnrc.yml   # optional: keep a node_modules folder
yarn install                     # rewrites yarn.lock in the new format

Keeping nodeLinker: node-modules makes the switch transparent for tools that expect node_modules; Plug'n'Play can be adopted later. Commit .yarnrc.yml, yarn.lock and the packageManager field, and add .yarn/cache, .yarn/install-state.gz and .pnp.* to .gitignore unless you want zero-installs.

Sources