create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Git error when trying to 'npm run eject'

Open martinpsz opened this issue 8 years ago • 12 comments

screen shot 2018-05-29 at 7 53 30 pm

I have run create-react-app and then ran npm run eject...also have tried yarn eject in the hopes of adding CSS Modules to my project. Unfortunately, I keep getting stuck on the above GIT error. I have tried what others with similar issues have recommended. I ran 'Git add .' and 'Git commit'. But that does not clear the issue. Searching the internet has not produced alternative solutions. I have even tried to gitignore all the listed files but nothing has worked.

I would like to understand why I am experiencing this issue and how I can clear it so I can successfully run npm run eject. Thanks!

martinpsz avatar May 29 '18 23:05 martinpsz

Before this message, you should see a list of untracked/changed files (I see "package.json"). These files are the reason why the script prevented you from ejecting. You can run git status which should produce the same list files.

Also, if you want CSS modules support, consider using CRA@2 which supports CSS modules out of the box without ejecting.

I've been using it in production and it is pretty stable.

bugzpodder avatar May 30 '18 01:05 bugzpodder

@martinpsz did you run the command correctly? Could send the output when executing the git status command!

rodrigooler avatar May 30 '18 04:05 rodrigooler

Please also copy/paste the entire output from npm run eject, thanks.

bugzpodder avatar May 30 '18 04:05 bugzpodder

@rodrigooler Here is a truncated output when I run 'git status':

screen shot 2018-05-30 at 11 37 40 am

Most of the files in the list and in the part that I didn't include are files that have nothing to do with this project. I am not even planning to put this React project on Github so I wonder if I can just bypass Git altogether?

@bugzpodder The output I pasted is the entire output. What I don't include can be seen in the truncated list I attach above when I ran git status.

martinpsz avatar May 30 '18 15:05 martinpsz

@martinpsz thanks for the additional information. I agree that these files are the ones that has nothing to do with this project. However, the create-react-app's eject script is not smart enough to make this distinction. I suggest you stash/ignore these files in order for eject will let you proceed.

bugzpodder avatar May 30 '18 15:05 bugzpodder

I am not that familiar with Git so pardon my ignorance. I copied and pasted the list of files, from the list I included a screenshot off, to the gitignore file in the project, saved it and ran npm run eject again to test...no change. Am I missing something? I would prefer to gitignore. Thank you for your help.

martinpsz avatar May 30 '18 16:05 martinpsz

It looks like you've added your entire home directory to a git repo. Assuming you didn't do that intentionally you can undo that by deleting the .git directory in the base directory (wherever you ran git init). Any changes you've made to that git repo will be lost though.

If you don't want to do that you could move your Create React App project to a directory outside of that git repo.

iansu avatar May 30 '18 16:05 iansu

@martinpsz did you have a problem with your versioning, can you locate and remove the .git folder? You need to find where the .git folder is to remove the untracked files.

rodrigooler avatar May 30 '18 23:05 rodrigooler

@martinpsz It seems to me that you created the .git folder inside the root -> "/", would not it work for you to run rm -rf /.git? Remember that you have to be careful when using the command rm -rf

rodrigooler avatar May 31 '18 00:05 rodrigooler

Ian and Rodrigo is right, if you remove the hidden .git/ directory from your home directory, you should see this issue go away. Let us know if you have additional issues!

bugzpodder avatar May 31 '18 16:05 bugzpodder

In my case, I ran yarn eject instead of npm run eject and it did what was intended. It had nothing to do with git.

kbbgl avatar Sep 20 '18 20:09 kbbgl

In my turn, i removed the git file from the project. Then i run the eject command. Then it's fine to run.

MonirTuhin avatar Nov 29 '18 03:11 MonirTuhin