git 运行“npm 运行弹出”时出错。错误“删除未跟踪的文件,隐藏或提交任何更改,然后重试。”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48854585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:03:47  来源:igfitidea点击:

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

gitreactjsnpmnpm-install

提问by Mr Singh

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

我尝试了很多方法来解决这个错误。

Command:'npm run eject'

命令:'npm 运行弹出'

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..

如何帮助解决这个问题..

回答by Mr Singh

I have tried this command it's worked:

我试过这个命令它的工作:

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

and then try again.

然后再试一次。

回答by Aravinth Raja

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

卸载 react-scripts 并安装 react-scripts-cssmodules 解决了问题

npm uninstall react-scripts

And then

进而

npm install react-scripts-cssmodules

then

然后

 npm run eject

Add it the git changes

添加它的 git 更改

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

回答by devDeejay

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.

这在消息中表示您有未跟踪的文件,这意味着您的 VCS 没有监控它们。因此,在弹出之前添加并提交它们。

If you are using Visual Studio Code:

如果您使用的是 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!

应该工作得很好。快乐黑客!

回答by Boopathi kumar

It is because you having the changed files

这是因为您拥有更改的文件

so initiate the new git repo

所以启动新的git repo

git init

then add all files to git

然后将所有文件添加到 git

git add .

once added commit the files

添加后提交文件

git commit -am "Saving before ejecting"

now you can eject the project using below command

现在您可以使用以下命令弹出项目

npm run eject

Happy Coding !!!!!!!

快乐编码!!!!!!!!!

回答by Mustak_Talukder

In my case, I found the solution here.

就我而言,我在这里找到了解决方案。

follow this may be it will helpful for you.

按照这个可能对你有帮助。

Step 1.

第1步。

create-react-app yourProjectName

step 2.

第2步。

cd yourProjectName

step 3.

第 3 步。

npm uninstall react-scripts

step 4.

第四步。

npm install react-scripts-cssmodules

step 5.

第 5 步。

git init

step 6.

第 6 步。

git add .

step 7.

第 7 步。

git commit -am "ejecting"

step 8.

第 8 步。

npm run eject

回答by samrat shakya

You need to commit your changes before running eject:

您需要在运行之前提交更改:

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

Now, Try

现在,试试

npm run eject

回答by Yilmaz

just delete git file in the project and then run the command: npm run eject

只需删除项目中的git文件,然后运行命令:npm run eject

in macos if you navigate to inside the project folder

在 macos 中,如果您导航到项目文件夹内

CMD + SHIFT + .

this will show hidden files.

这将显示隐藏文件。

回答by YASH THUMAR

Just make commit bc commit is necessary before leaving the project

在离开项目之前,只需 make commit bc commit 是必要的

PC MINGW64 ~/react/react2/myapp (master)
$ git commit -am "first commit for before ejecting"

and Then eject with this command

然后用这个命令弹出

$ npm run eject

回答by naga

Check if any of the below tow options work for you :

检查以下任何两个选项是否适合您:

  • Uninstalling and Re-installing the react-scripts-cssmodules :

    npm uninstall react-sctipts

    npm install react-scripts-cssmodules

    npm run eject

  • Committing the changes of the GIT repository:

    git add .

    git commit -am "Save before ejecting"

  • 卸载并重新安装 react-scripts-cssmodules :

    npm 卸载 react-sctipts

    npm install react-scripts-cssmodules

    npm 运行弹出

  • 提交 GIT 存储库的更改

    git 添加。

    git commit -am "退出前保存"

If any of the above two solutions do not work, and IF Git is not necessary for your current project, then go to

如果以上两种解决方案中的任何一种都不起作用,并且如果您当前的项目不需要 Git,则转到

Control Panel -> Programs -> Select "Git"and then UN-INSTALL.

控制面板 -> 程序 -> 选择“ Git,然后选择UN-INSTALL

Now run the "npm run eject" again.

现在再次运行“ npm run eject”。

It should work fine now. You can go ahead and reinstall GIT again whenever necessary

现在应该可以正常工作了。您可以继续并在必要时再次重新安装 GIT