Copy link to headingDoes Vercel support Yarn?
Yes. Vercel supports Yarn Classic (1.x) and the Berry line, including Yarn 2, Yarn 3, and Yarn 4. A yarn.lock file on its own tells Vercel to install with Yarn 1, so a project on a newer release has to declare its version through Corepack or a committed Yarn binary.
Copy link to headingWhich Yarn versions does Vercel support?
All four Yarn releases run on Vercel, and what you configure depends on which one you're on:
| Yarn version | Latest release | How Vercel runs it |
|---|---|---|
| Yarn 1 (Classic) | 1.22.22 | Selected automatically when yarn.lock is present. Nothing to configure. |
| Yarn 2 (Berry) | 2.4.3 | Corepack, or a release committed to .yarn/releases. |
| Yarn 3 (Berry) | 3.8.7 | Corepack, or a release committed to .yarn/releases. |
| Yarn 4 (Berry) | 4.18.0 | Corepack, or a release committed to .yarn/releases. |
Vercel detects your package manager from the lock file in your repository. For npm and pnpm, it reads a lockfileVersion field to pick the version, and yarn.lock carries no equivalent, which is why a Yarn project defaults to Yarn 1.
Yarn 2 stopped at 2.4.3, and Yarn 3's last release was 3.8.7 in December 2024, so new projects should target Yarn 4.
Copy link to headingHow to use Yarn 4 on Vercel
Two routes get Yarn 4 running on a Vercel build. Corepack reads the version from your package.json, and the other stores the Yarn release in your repository.
Copy link to headingEnable Corepack for your project
Corepack ships with Node.js 16 and later, and it selects the package manager version from the packageManager field in package.json. On Vercel, an environment variable turns it on.
To enable Corepack:
- Run
yarn set version 4.18.0in your project root to write thepackageManagerfield. - Commit the updated
package.json. - In the Vercel dashboard, open your project and select Settings, then Environment Variables.
- Add a variable named
ENABLE_EXPERIMENTAL_COREPACKwith the value1. - Redeploy the project.
The field Corepack reads on each build looks like this:
Pin an exact version rather than a range, so every build and every developer machine runs the same Yarn release. Corepack is experimental in Node.js, and its behavior can change between Node.js releases.
Copy link to headingCommit a Yarn release to .yarn/releases
The second route keeps the Yarn binary in your repository. Yarn Classic reads the yarnPath setting from .yarnrc.yml and hands the install to the release it points at, which is how a build reaches Yarn 4 without Corepack.
Run this in your project root:
The command downloads the release into .yarn/releases and writes the path into .yarnrc.yml:
Commit both the release file and .yarnrc.yml. If the binary is missing from the repository, the install fails with an error reporting that the yarn-path location doesn't exist.
Copy link to headingKeep the cache in the repository for zero-installs
Yarn 4 stores its cache globally by default, so a zero-install setup needs enableGlobalCache set to false in .yarnrc.yml. That writes package archives into .yarn/cache inside the project, where you can commit them alongside your code. A Vercel build clones your repository before the install step, so a committed cache is on disk by the time yarn install runs.
Copy link to headingHow Vercel handles Yarn 2 and Yarn 3
Yarn 2 and Yarn 3 use the same two routes as Yarn 4. Enable Corepack and pin the version in packageManager, or run yarn set version 3.8.7 --yarn-path (or yarn set version 2.4.3 --yarn-path) to commit a release into .yarn/releases.
Plug'n'Play has been Yarn's default install mode since Yarn 2, so a Berry project installs without a node_modules directory unless it opts out. Some build tooling still expects that directory to exist.
To install into node_modules instead, set the linker in .yarnrc.yml:
Yarn's migration guide covers the rest of the move from Yarn Classic to a Berry release, including lockfile and configuration changes that apply before your first deployment.
Copy link to headingHow to troubleshoot Yarn version detection on Vercel
When a build installs with the wrong Yarn version, the repository and the build environment disagree about which version to use.
Check these in order:
- Corepack environment variable: Confirm
ENABLE_EXPERIMENTAL_COREPACKis set to1on the environment you deployed to, since Preview and Production are scoped separately. - The
packageManagerfield: Confirm it's committed and pins a full version, such asyarn@4.18.0. - The committed release: Confirm
.yarn/releasesand.yarnrc.ymlare both in the repository, and that.gitignoreisn't excluding.yarn. - The install command: An Override in Build & Development Settings, or an
installCommandinvercel.json, replaces the detected install command.
Your build logs name the package manager and version used for the install, so you can confirm which setting won.
Copy link to headingNext steps
With the Yarn version pinned in your repository, the project is ready to deploy. Start a new Vercel project to import it, or browse the templates for a framework-ready starting point.
Copy link to headingRelated resources
Copy link to headingFAQ
How do I enable Corepack on a Vercel project?
Add an environment variable named ENABLE_EXPERIMENTAL_COREPACK with the value 1 to your project, then set the packageManager field in package.json to an exact Yarn version such as yarn@4.18.0. Redeploy for the change to take effect. Corepack is experimental in Node.js, so its behavior can change between Node.js releases.
Why does my Vercel build still install Yarn 1?
Vercel picks the package manager from your lock file, and a yarn.lock file on its own resolves to Yarn 1. To run a Berry release, either enable Corepack and pin the packageManager field, or commit a Yarn release to .yarn/releases with yarnPath set in .yarnrc.yml. Both live in the repository.
Can different projects use different Yarn versions on Vercel?
Yes. Both configuration routes live in the repository, so each project pins its own version. Corepack reads the packageManager field from that project's package.json, and the committed-release route reads yarnPath from that project's .yarnrc.yml. Two projects on the same team can run different Yarn versions.
Does Vercel support Yarn Plug'n'Play?
Plug'n'Play is Yarn's default install mode from Yarn 2 onward, and a Vercel build runs whichever mode your repository configures. Dependencies are resolved through the generated .pnp.cjs file instead of a node_modules directory. If a tool in your build needs node_modules, set nodeLinker: node-modules in .yarnrc.yml.