简体   繁体   中英

using create-react-app I get EEXIST: file already exists

I am making my first react app and running command: npx create-react-app my-app and i am getting this error:

Error: EEXIST: file already exists, mkdir 'C:\Users\Deepak'

command not found: create-react-app

Can anybody please help me to resolve this error?

It seems you have a my-app folder/directory in C:\Users\Deepak . Could you try as below?

npx create-react-app my-super-app

It seems you have a space in your users directory Deepak . That is the most common reason for this type of error.

NPX uses C:\Users\[username]\AppData\Roaming\npm-cache while executing. It has a bug which prevents it from running if there is space in this path.

To remedy this problem you need to update the npm cache path by replacing the string after the space with ~1

Eg

npm config set cache C:\Users\Deepak~1\AppData\Roaming\npm-cache

This will set npm cache path without the space.

After this if you run npx it should work fine without throwing any error.

NOTE: You might want to run this command and the npx command with administrative rights or you might get permission error

Follow these steps, it will definitely work:

  1. npm uninstall -g create-react-app
  2. npm install -g create-react-app
  3. npx create-react-app the-name-of-your-app

I do have space in my UserName folder so I tried this run the command

npm config edit

set the variable cache=C:\Users\{UserName} and save the file

This work in my case, hope it will help u too

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM