Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Yarn Command Not Found on Windows? Fix It Fast

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

"yarn command not found" on Windows means the Yarn package manager is not installed, or its install folder is not on your PATH. The quickest fix is to install Yarn through npm (which ships with Node.js) and then open a new terminal window so Windows picks up the updated PATH. If Yarn is already installed, the same error usually means the terminal was opened before the install finished, or the PATH entry is missing. The steps below cover both cases.

What You'll Need

  • A Windows PC with an internet connection.
  • Node.js and npm installed. You can check by opening Command Prompt and running node -v and npm -v. If either says "not recognized", install the current LTS version of Node.js from the official nodejs.org website first.
  • Access to a terminal: Command Prompt, PowerShell, or Windows Terminal. The steps work the same in all three, though menu labels can differ slightly by Windows version.
  • Administrator rights if you plan to change system environment variables.

Step-by-Step

  1. Close every terminal window. PATH changes only apply to terminals opened after the change. If you installed Node.js or Yarn recently, open a fresh Command Prompt and try yarn --version again before doing anything else.
  2. Confirm Node.js and npm are working. In the new terminal, run node -v and npm -v. Both should print a version number. If they do not, install Node.js from the official site, then close and reopen the terminal.
  3. Install Yarn globally with npm. Run npm install --global yarn. This downloads Yarn from the npm registry and places its launcher in npm's global bin folder. Wait for the command to finish without errors.
  4. Verify the install location. Run npm config get prefix. This prints the folder where npm puts global packages, for example C:\Users\YourName\AppData\Roaming\npm. Yarn's launcher should be inside that folder.
  5. Open a new terminal and test. Close the current window, open a new Command Prompt, and run yarn --version. A version number means you are done. If you still get "not found", continue to the next step.
  6. Check whether the npm prefix is on your PATH. In Command Prompt, run echo %PATH% (in PowerShell, run $env:PATH). Look for the folder printed in step 4. If it is missing, you need to add it.
  7. Add the folder to PATH. Open the Start menu, search for "environment variables", and choose the option to edit the system environment variables. In the window that opens, click Environment Variables. Under User variables, select Path and click Edit. Click New and paste the npm prefix folder from step 4. Click OK on each window to save. This changes your user account only, not the whole system.
  8. Reopen the terminal and test again. Close all terminal windows, open a new one, and run yarn --version. It should now print a version.
  9. If you prefer not to use npm, use the official installer. Yarn also provides a Windows installer on its official website (classic.yarnpkg.com). Download and run it, accept the default options, and it will add Yarn to your PATH automatically. Close and reopen your terminal afterwards.

Common Mistakes

  • Testing in the same terminal. The most common cause of a failed fix is running yarn --version in the window that was open before the install. Always open a new terminal.
  • Installing Node.js but not reopening the terminal. Node.js adds itself to PATH during setup, but existing terminals do not see the change.
  • Using npm install yarn without --global. That installs Yarn into the current project's node_modules folder only, so the yarn command is not available everywhere. Use the global flag.
  • Editing the system PATH when the user PATH is enough. Changing system variables requires administrator rights and affects every account. For a single-user machine, the user PATH is simpler and safer.
  • Mixing installers. If you installed Yarn with the official installer, do not also install it globally with npm; two copies can conflict. Pick one method and stick with it.
  • Typos in the PATH entry. A missing backslash or an extra space at the end of the folder path will stop Windows from finding yarn.cmd.

Tips

  • Run where yarn in Command Prompt to see exactly which file Windows finds. If it prints nothing, the PATH is still wrong.
  • Use Windows Terminal or PowerShell rather than the older Command Prompt if you switch between projects often; both respect the same PATH.
  • If you use a version manager for Node.js, install Yarn through that manager's own instructions instead of a global npm install, so the two stay in sync.
  • Keep Node.js updated to a current LTS release. Very old Node.js versions can ship an npm too old to install recent Yarn releases cleanly.
  • After any PATH change, log out and back in if a new terminal still does not see it; some apps cache the environment at sign-in.

Troubleshooting

If yarn --version still fails after the steps above, work through these checks in order.

  1. Confirm the file exists. Open File Explorer and navigate to the npm prefix folder from step 4. You should see yarn.cmd and related files. If the folder is empty, the global install did not complete; run npm install --global yarn again and read any error messages.
  2. Permission errors during install. If npm reports access denied, run the terminal as administrator for the install, or fix the folder permissions on the npm prefix directory. Do not disable security software to force it through.
  3. Corporate proxy or firewall. If the install hangs or fails to reach the registry, npm may need proxy settings configured. Check with your IT team before changing network settings.
  4. PATH entry looks right but still fails. Open a new terminal and run echo %PATH% to confirm the entry actually saved. Sometimes the Environment Variables dialog is closed with Cancel instead of OK.
  5. Conflicting Yarn installs. Run where yarn. If it lists a file in a project folder, that local copy may be broken. Remove the project's node_modules folder and reinstall dependencies with npm install or a working global Yarn.
  6. Last resort: reinstall. Uninstall Yarn through Settings > Apps if it appears there, or run npm uninstall --global yarn, then repeat the install steps. This removes only the Yarn package, not your projects.

Frequently Asked Questions

Do I need Node.js to use Yarn on Windows?

For the npm install method, yes. Yarn's official standalone installer does not require Node.js, but most Yarn projects expect Node.js to be present anyway.

Why does yarn work in one terminal but not another?

The terminal that fails was probably opened before the PATH change. Close it and open a new one.

Should I use npm or the official installer?

Either works. npm keeps Yarn updated alongside your other global tools; the installer is simpler if you do not want to manage global npm packages. Do not use both at once.

Does changing PATH affect other programs?

Adding one folder to your user PATH only makes that folder searchable for commands. It does not change existing entries, but a malformed edit can break other commands, so edit carefully and keep a note of the original value.

Can I install Yarn only for one project?

Yes. Running npm install yarn inside a project adds it locally, but you then run it through npm scripts or npx yarn, not as a bare yarn command.

Why does PowerShell block the yarn command?

PowerShell's script execution policy can block .ps1 launchers. The yarn.cmd launcher usually works in Command Prompt. If PowerShell refuses, check the execution policy documentation or use Command Prompt for Yarn commands.