Create-react-app: Option to overwrite conflicting files while creating new app

Created on 12 Jul 2017  路  8Comments  路  Source: facebook/create-react-app

Currently, creation of a new app will fail if the folder has files which will be added by create-react-app.
screen shot 2017-07-13 at 1 46 04 am

It would be nice to have an option which allows us to let create-react-app overwrite those conflicting files. Simple initialisations like npm init and git init before CRA in an existing folder can lead to this failure via conflicts.

proposal

Most helpful comment

Trying to run this in e.g. Cloud 9, I find that Cloud 9 continuously creates a .c9 folder (working area for the IDE) which reappears as soon as I remove it. Only alternative seems to be creating in a subfolder, then moving everything up a level :/

All 8 comments

I agree we should be resilient to git init.

But if you already have a package.json there I don鈥檛 think it鈥檚 okay to rewrite it. If you鈥檙e okay with adding a flag, I don鈥檛 see why adding a rm command before the call would be problematic.

I believe we already are resilient to git init; just not package.json.

If you鈥檙e okay with adding a flag, I don鈥檛 see why adding a rm command before the call would be problematic.

Mainly because the message before failure gives no clue about the conflicts.
"contains files that could conflict" is not helpful.

It is possibly easier to think about this scenario if we consider a use case

  • I am setting up a new project
  • I have initialised a new git project or cloned from a barebones project which only has a readme and gitignore
  • I have setup vagrant and related configs
  • I am setting up my react app via non create-react-app methods
  • I decide other methods are not working for so I pick up create-react-app
  • create-react-app now throws an error "contains files that could conflict" and fails
  • how do I proceed?

Relatedly now that npm 5.2 has added npx, I no longer want to have global node modules. So I would like to be able to do the following:

  • mkdir myapp
  • cd myapp
  • npm install create-react-app
  • npx create-react-app .

Currently, the above would throw an error as the folder contains

  • node_modules
  • package-lock.json

screen shot 2017-07-13 at 2 01 54 pm

This sequence doesn鈥檛 quite make sense to me:

npm install create-react-app
npx create-react-app .

Why are you installing it locally?

Just

mkdir myapp
cd myapp
npx create-react-app .

should work fine.

Or, easier,

npx create-react-app my-app

"contains files that could conflict" is not helpful.

I agree we should include a list of these files in the message. I鈥檓 filing an issue for this.

I am setting up my react app via non create-react-app methods
I decide other methods are not working for so I pick up create-react-app
create-react-app now throws an error "contains files that could conflict" and fails
how do I proceed?

Do it in a different folder, or clean the existing folder. I don鈥檛 see a problem here. If CRA overwrote your work it could potentially destroy valuable files. You could accidentally run it in a wrong directory. I think the current behavior is correct.

I鈥檒l close this but filed https://github.com/facebookincubator/create-react-app/issues/2780 for better error message. Thanks for explaining!

Trying to run this in e.g. Cloud 9, I find that Cloud 9 continuously creates a .c9 folder (working area for the IDE) which reappears as soon as I remove it. Only alternative seems to be creating in a subfolder, then moving everything up a level :/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

godmar picture godmar  路  130Comments

gaearon picture gaearon  路  152Comments

sgriffey picture sgriffey  路  113Comments

gaearon picture gaearon  路  86Comments

razvan-soare picture razvan-soare  路  161Comments