yarn
yarn copied to clipboard
cannot run yarn create if yarn is in a folder where the file path has a space
Yarn v1.12.3 my laptop (helpfully, thank you windows) installed yarn by default in a directory where the file path includes a space (e.g. C:/Users/Some Name/AppData/Yarn...). This results in the following error when I run yarn create react-app
'C:\Users\Some' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:\Users\Some Name\AppData\Local\Yarn\bin\create-react-app
Arguments:
Directory: C:\repos\beaver
Output:
Just spent an hour on this very issue until realizing this was the cause - spaces in the profile name.
If easy, putting quotes around the command would resolve it and still work with non-spaced paths
It's been a year now, can we get an update on this?
You need to change the cache to a location without spaces.
yarn config set cache-folder "your path without spaces"
Did work for me!! If this solve your problems, let me know!
I also had to change the prefix
yarn config set prefix "your path without spaces"
#6630
It is now 2021 and this is still not fixed.
nvm puts node in C:\Program Files\nodejs
yarn create puts the creator in [node directory]\bin
The result of every yarn create whatever is
success Installed "[email protected]" with binaries:
- create-react-app
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:\Program Files\nodejs\bin\create-react-app
npm/npx doesn't have this problem.
I have a fix and proposed solution for this!
It involves around changing the config, but I hope the devs try to make a workaround around spaced folder by utilizing FolderName~1 style solution.
Solution for the meantime:
First, run these commands
yarn cache dir
yarn global bin
It'll output something like:
C:\Users\Firstname Lastname\AppData\Local\Yarn\Cache\v6
C:\Users\Firstname Lastname\AppData\Local\Yarn\bin
Copy those, and next run this, with slight modification according to your username Firstname:
yarn config set cache-folder "C:\Users\Firstname~1\AppData\Local\Yarn\Cache" (without the V6)
yarn config set prefix "C:\Users\Firstname~1\AppData\Local\Yarn" (without the bin)
This is not a workaround, this is a fix, and other workarounds that revolves around moving your Yarn configs to a new folder may cause PATH or Environment Variables issue!
Hope this fixes your problem.
@ZombieChibiXD's solution did not work for me, but combining their solution with the solution proposed over at https://github.com/vitejs/create-vite-app/issues/23#issuecomment-706492641 for npm did.
Problematic path used as example: C:\Users\Espen Jacobsson
Steps taken:
- Close any running shell
- Run
cmdin Administrative Mode (mklinkis a feature ofcmd, and won't work inPowerShell) - Create a directory junction (directory hard link) using the mklink command:
mklink /J "C:\Users\EspenJacobsson" "C:\Users\Espen Jacobsson"
- Run commands
yarn cache diryarn global bin
Take note of the output, as stated in the comment above, they will look something like this:
C:\Users\Espen Jacobsson\AppData\Local\Yarn\Cache\v6
C:\Users\Espen Jacobsson\AppData\Local\Yarn\bin
-
Run commands:
yarn config set cache-folder "C:\Users\EspenJacobsson\AppData\Local\Yarn\Cache"(without theV6)yarn config set prefix "C:\Users\EspenJacobsson\AppData\Local\Yarn"(without thebin)
-
Reload your shell and verify the new paths are set with the
yarn cache dirandyarn global bincommands -
Assuming the paths are correctly changed,
yarn createshould now hopefully be working
Hope this helps anyone 🙂
@ZombieChibiXD's solution looks fancy, but it doesn't work for everyone.
The right way to find the short path should be running dir /x in C:\Users.

It's VALORL~1 for me instead of VALOR~1.
I have a fix and proposed solution for this! It involves around changing the config, but I hope the devs try to make a workaround around spaced folder by utilizing
FolderName~1style solution.Solution for the meantime:
First, run these commands
yarn cache diryarn global binIt'll output something like:
C:\Users\Firstname Lastname\AppData\Local\Yarn\Cache\v6C:\Users\Firstname Lastname\AppData\Local\Yarn\binCopy those, and next run this, with slight modification according to your username Firstname:
yarn config set cache-folder "C:\Users\Firstname~1\AppData\Local\Yarn\Cache"(without theV6)yarn config set prefix "C:\Users\Firstname~1\AppData\Local\Yarn"(without thebin)This is not a workaround, this is a fix, and other workarounds that revolves around moving your Yarn configs to a new folder may cause PATH or Environment Variables issue!
Hope this fixes your problem.
After hours of struggling with this issue, @ZombieChibiXD solution worked for me.
You need to change the cache to a location without spaces.
yarn config set cache-folder "your path without spaces"
Did work for me!! If this solve your problems, let me know!
HOW?

Still a problem in 2022, incredible...
This is happening to me too .... :( My laptop is a company laptop with was pre--setup by someone else, who wasnt aware of spaces being a problem. Is there any fix for this?
Edit: Just for info, https://github.com/yarnpkg/yarn/issues/6851#issuecomment-953366835 worked for me too.
I too am amazed to find this is still a problem in 2022. On Windows we've regularly had spaces in directory names since Windows 95, and on Linux the first ext file system had it since 1992. This should not still be a problem 27/30 years later.
Many of the workarounds above will not work because the Yarn configuration file ".yarnrc" exists in our user home directory which is a very common place for a space to be present at, so any configuration change you make (even with the junction or symbolic link approach) will not persist.
yarn config set cache-folder "C:\path\without\spaces\.yarn-cache"
yarn config set prefix "C:\path\without\spaces\.yarn"
just run these two command and confirm changes using this command
yarn config list
Thank me later <3
Run this command in command prompt:
yarn config set prefix "\AppData\Local\bin"
U are good to go