yarn is not recognized when running a React Native project
'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.
Fix it fast
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 --version2Match what you see, then jump to its fix
- 1
corepack --version prints a version, but yarn is still not found.Corepack is installed but not enabledFix - 2
corepack --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
You installed Node.js through Volta.Node.js is managed by VoltaFix
- 1
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 --version2Fix
Enable the shims, then open a new terminal so the PATH is read again.
corepack enable3Verify
The Yarn docs suggest running exec env: it prints a path when Corepack is set up properly.
yarn exec envConfirmed by yarnpkg.com
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 --version2Fix
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 enable3Verify
Open a new terminal and ask for the Yarn path.
yarn exec envConfirmed by github.com
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 node2Fix
Install Corepack with npm and write the shims into the Volta bin directory.
npm install -g corepack
corepack enable --install-directory ~/.volta/bin3Verify
Open a new terminal and run Yarn inside the project.
yarn exec envConfirmed by yarnpkg.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb 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 fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fix