Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

yarn is not recognized when running a React Native project

Error'yarn' is not recognized as an internal or external command, operable program or batch file.

Short answer

The shell cannot find a yarn launcher on your PATH. Current Yarn is meant to come through Corepack, which is opt-in. Run corepack enable. On Node.js 25 and later Corepack is no longer bundled, so install it with npm first. Close and reopen the terminal afterwards.

  • Applies to Node.js 22, Node.js 24, Yarn via Corepack, Windows 11
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check whether Corepack exists and which Node.js you run. The answer picks the cause below.

    node --version
    corepack --version
  2. 2Match what you see, then jump to its fix

    1. 1corepack --version prints a version, but yarn is still not found.Corepack is installed but not enabledFix
    2. 2corepack --version says corepack is not recognized or not found.Your Node.js has no Corepack (Node.js 25 and later, or a distro package)Fix
    3. 3You installed Node.js through Volta.Node.js is managed by VoltaFix

What does the error look like?

  • 'yarn' is not recognized as an internal or external command, operable program or batch file.

Cause 1 of 3

Corepack is installed but not enabled

1Check

Corepack ships with Node.js releases from 14.19 and 16.9, but you must opt in. Until you do, no yarn launcher exists.

corepack --version

2Fix

Enable the shims, then open a new terminal so the PATH is read again.

corepack enable

3Verify

The Yarn docs suggest running exec env: it prints a path when Corepack is set up properly.

yarn exec env

Confirmed by yarnpkg.com

Did this fix it?

Cause 2 of 3

Your Node.js has no Corepack (Node.js 25 and later, or a distro package)

1Check

Corepack is bundled with Node.js from 14.19.0 up to, but not including, 25.0.0. Some system package managers leave it out as well.

node --version

2Fix

Install Corepack with npm, then enable it. Remove any global yarn first so the two do not clash.

npm uninstall -g yarn pnpm
npm install -g corepack
corepack enable

3Verify

Open a new terminal and ask for the Yarn path.

yarn exec env

Confirmed by github.com

Did this fix it?

Cause 3 of 3

Node.js is managed by Volta

1Check

Volta does not integrate with Corepack by default, so corepack enable writes shims to a folder that is not on your PATH.

where node

2Fix

Install Corepack with npm and write the shims into the Volta bin directory.

npm install -g corepack
corepack enable --install-directory ~/.volta/bin

3Verify

Open a new terminal and run Yarn inside the project.

yarn exec env

Confirmed by yarnpkg.com

Did this fix it?

How do I stop it coming back?

  • Run corepack enable once on every new machine and CI image that has Node.js.
  • Avoid npm install -g yarn: the Yarn docs advise against a global binary because it is not pinned per project.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

Jest fails to parse a React Native or Expo dependency

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax

Jest does not run Babel on node_modules by default, and many React Native packages ship untranspiled source.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.