Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yarn gives error when creating react application

I get the below error when running "yarn create react-app app"

I understand that this is because of the spaces present in my system username . How do I run this command such that I don't have to change my system username

success Installed "[email protected]" with binaries:
      - create-react-app
[################################################################] 
64/64'C:\Users\ted' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:\Users\ted mosby\AppData\Local\Yarn\bin\create-react-app
Arguments: app
Directory: D:\Projects\react

I can't find the application in the above mentioned directory

like image 280
stackMan10 Avatar asked Jun 08 '26 21:06

stackMan10


1 Answers

This method is just a workaround.

On Windows, if your user profile has a space in it which it often has since Windows wants your full name.

For example:

C:\Users\John Doe

Running yarn create next-app will fail with

'C:\Users\John' is not recognized as an internal or external command.

If setting cache folder for yarn and npm does not seem to work, try changing the environment variable LOCALAPPDATA which points to the app data in your home directory.

First, check 8.3 directory name with

dir C:\Users /x

C:\Users\John should look like C:\Users\JOHN~1.

Then, set the environment variable with

set LOCALAPPDATA=C:\Users\JOHN~1\AppData\Local

Now, yarn create should work.

like image 51
Chayapol Avatar answered Jun 10 '26 16:06

Chayapol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!