stackMan10
stackMan10

Reputation: 742

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

Upvotes: 3

Views: 2761

Answers (3)

lamsal
lamsal

Reputation: 334

For Windows users with space in their username, this is still an open issue and here is the as workaround mentioned in this comment.

yarn config set cache-folder c:\root\yarn\cache
yarn config set prefix c:\root\yarn\packages

Upvotes: 0

Chayapol
Chayapol

Reputation: 3934

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.

Upvotes: 8

Abulafia
Abulafia

Reputation: 1765

From what I can gather from:

https://github.com/yarnpkg/yarn/issues/5717

You may have a chance by upgrading to Node 11.1.0 (and, one assumes, higher) or using yarn 1.5.1 instead. (I would definitely encourage attempting the Node upgrade first. You may want to look into https://github.com/coreybutler/nvm-windows to manage your node versions sensibly.)

I'm sure these issues are related, but adding your use-case may well encourage work to accelerate.

Upvotes: 0

Related Questions