Skip to content

Yarn

Yarn installs JavaScript dependencies and runs project commands.

Visit Yarn

How can you tell which Yarn a project expects?

Start with the README and the packageManager field in package.json. Yarn Classic is Yarn 1. Modern Yarn has different configuration and install behavior. Both use a file named yarn.lock, so the filename alone cannot settle which instructions apply.

Look for any project-managed release under .yarn/releases and the matching setting in .yarnrc.yml. If the documentation and files disagree, check the automated build configuration before changing them.

Do Node.js and Yarn use the same version?

The project can require one Node.js release to run its code and a separate Yarn release to install dependencies. Corepack can find the project’s Yarn pin and start that version. It may download the manager if it is not already cached.

The official Node.js distribution stopped bundling Corepack at Node.js 25. Some other distributions omit it too. Check how your project and build provide the manager before relying on an existing Corepack command.

Can you check the setup without running Yarn?

Use paper and two invented project descriptions. Leave your terminal, package registries and project files alone.

  1. Read the clues
    Project A says Yarn Classic in its README. Project B pins Yarn 4 in package.json and has .yarnrc.yml. Both contain yarn.lock. Write which documentation belongs to each.
  2. Check a changed dependency
    Pretend that Project B now asks for a new major dependency version while its lockfile still has the old one. Write that an immutable install should stop and that an intentional update needs review.
  3. Check the build machine
    Pretend Project B uses Node.js 25 on a new machine. Write down how you would find out whether its Yarn version is available before relying on the build.

What should you keep so another machine can install the same project?

Keep the manifest, yarn.lock and the project’s relevant Yarn configuration together. Match the Node.js and Yarn versions and the dependency layout. Modern Yarn can use Plug’n’Play, a way to locate packages without a conventional node_modules folder, or a node_modules setup if the project chooses it.

Modern Yarn uses the immutable install option to reject lockfile changes. Yarn Classic documents its frozen lockfile option for that job. These checks do not make a dependency safe to run. Read project scripts and build settings before installing in an unfamiliar project. Yarn is open-source software. A private registry or build service may have separate costs.