Chris's coding blog

How to fix yarn global add command not found on Windows

November 04, 2020

If you try to run yarn global add gatsby on Windows and then try to run gatsby you might get an error message “command not found”. This is because the yarn bin folder isn’t in your user’s $PATH environmental variable.

There’s an easy fix for it in Powershell, I’ve also put it in this gist.

$yarnPath = & yarn global bin $path = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User) [System.Environment]::SetEnvironmentVariable("PATH", "$path;$yarnPath", [System.EnvironmentVariableTarget]::User) # Your yarn path should appear at the end of the path now [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User) # Try a global command, for example gatsby. If you're using Visual Studio Code, you'll need to restart the IDE gatsby

I'm Chris Small, a software engineer working in London. This is my tech blog. Find out more about me via GithubStackoverflowResume