Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to overwrite conflicting files while creating new app #2776

Closed
supreetpal opened this issue Jul 12, 2017 · 8 comments
Closed

Option to overwrite conflicting files while creating new app #2776

supreetpal opened this issue Jul 12, 2017 · 8 comments

Comments

@supreetpal
Copy link

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.

@gaearon
Copy link
Contributor

gaearon commented Jul 12, 2017

I agree we should be resilient to git init.

But if you already have a package.json there I don’t think it’s okay to rewrite it. If you’re okay with adding a flag, I don’t see why adding a rm command before the call would be problematic.

@Timer
Copy link
Contributor

Timer commented Jul 13, 2017

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

@supreetpal
Copy link
Author

supreetpal commented Jul 13, 2017

If you’re okay with adding a flag, I don’t 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?

@supreetpal
Copy link
Author

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

@gaearon
Copy link
Contributor

gaearon commented Jul 13, 2017

This sequence doesn’t 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

@gaearon
Copy link
Contributor

gaearon commented Jul 13, 2017

"contains files that could conflict" is not helpful.

I agree we should include a list of these files in the message. I’m 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’t 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.

@gaearon
Copy link
Contributor

gaearon commented Jul 13, 2017

I’ll close this but filed #2780 for better error message. Thanks for explaining!

@gaearon gaearon closed this as completed Jul 13, 2017
@goofballLogic
Copy link

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 :/

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants