解決create-react-app后,運(yùn)行npm run eject報錯問題。

  • 問題重現(xiàn):在Mac環(huán)境下使用create-react-app腳手架工具新建項目后,運(yùn)行npm run eject后報錯,報錯信息如下:
Remove untracked files, stash or commit any changes, and try again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mymanagers@0.1.0 eject: `react-scripts eject`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mymanagers@0.1.0 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!     /Users/xxx/.npm/_logs/2019-07-16T10_16_47_555Z-debug.log
  • 問題原因:腳手架工具為您的項目添加了.gitgnore文件,但是卻沒有本地倉庫。
  • 解決辦法:
#cd 你的項目目錄
#git init
#git add .
#git commit -m "saving before ejecting"
#npm run eject
  • 補(bǔ)充知識:eject(彈射)命令做的事情。將潛藏在react-script中的一系列技術(shù)棧配置項都彈射到應(yīng)用的頂層,然后就可以更靈活的定制研究修改這些配置細(xì)節(jié)。
  • 執(zhí)行 npm run eject 之后會生成新的文件:
    eject生成的目錄結(jié)構(gòu).png
  • 因reject過程 不可逆,所以非必須可以不必執(zhí)行此操作。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容