react 使用create-react-app命令创建一个项目,运行npm run eject命令暴露配置文件都报这个错误
原因:主要是脚手架添加 .gitgnore文件,但是却没有本地仓库
错误:
Remove untracked files, stash or commit any changes, and try again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-app@0.1.0 eject: `react-scripts eject`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-app@0.1.0 eject script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
解决:
create-react-app my-react-app
cd my-react-app
git init
git add .
git commit -m 'Saving before ejecting'
npm run eject
按照以上顺序就可以正常使用
网友评论