Error with run "npm run eject". Error 'Remove untracked files, stash or commit any changes, and try again.'

16,621

Solution 1

I have tried this command it's worked:

git add .
git commit -am "Save before ejecting"

and then try again.

Solution 2

Uninstalling react-scripts and installing react-scripts-cssmodules solved the problem

npm uninstall react-scripts

And then

npm install react-scripts-cssmodules

then

 npm run eject

Add it the git changes

git add .
git commit -am "Save before ejecting"

Solution 3

This says in the message that you have untracked files that means that they are not being monitored by your VCS. Hence add and commit them before you eject.

If you are using Visual Studio Code:

  • Just click on the third icon (Source Control), below the magnifying glass button
  • Then click on the tick mark, if it asks to automatically stage your changes Click Yes
  • Add your commit message and then you are done

enter image description here

Try ejecting again,

npm run eject

Should work just fine. Happy Hacking!

Solution 4

You need to commit your changes before running eject:

git add .
git commit -am "change messages before running eject"

Now, Try

npm run eject

Solution 5

In my case, I found the solution here.

follow this may be it will helpful for you.

Step 1.

create-react-app yourProjectName

step 2.

cd yourProjectName

step 3.

npm uninstall react-scripts

step 4.

npm install react-scripts-cssmodules

step 5.

git init

step 6.

git add .

step 7.

git commit -am "ejecting"

step 8.

npm run eject
Share:
16,621
Mr Singh
Author by

Mr Singh

Python/BlockChain/Django developer.

Updated on July 21, 2022

Comments

  • Mr Singh
    Mr Singh almost 2 years

    I have try lot's of things to solve this error.

    Command:'npm run eject'

    Remove untracked files, stash or commit any changes, and try again.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] eject: `react-scripts eject`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the [email protected] eject script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/deep/.npm/_logs/2018-02-18T17_05_02_924Z-debug.log
    

    How can help to solve this problem..

  • Boopathi kumar
    Boopathi kumar about 5 years
    I can't use git add . without initiating new git if any other git already initialized. Its not mentioned in above answers so i posted here. This solves my problem
  • cronoik
    cronoik about 5 years
    Please add some explanations to your steps (e.g. why do you need git?).
  • Mustak_Talukder
    Mustak_Talukder about 5 years
    when I want to do that I found the above problem, then search google and try different way but nothing happened then I try this and solve my problem.
  • Maugham
    Maugham over 2 years
    the other methods: 1, rm -rf .git of the root program 2, npm run eject
  • Amin AmiriDarban
    Amin AmiriDarban about 2 years
    nice & easy. Works..! thanks