react-create-app 添加 less/解决 npm run eject报错

想要添加less 需要暴露 webpack.config 配置文件 先打开项目根目录命令行运行 npm run eject:运行之后,我们发现多了一个config文件夹

如果运行后 点击y/n 确认(y),报错了:报错信息为:

Remove untracked files, stash or commit any changes, and try again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@0.1.0 eject: `react-scripts eject`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@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:
那么时因为 脚手架添加.gitgnore文件,但是却没有本地仓库,(或者时有本地仓库没有初始化 init)
只要按顺序 执行下git 提交 再运行npm run eject 即可
create-react-app test//不是必须如果打开原有项目可以忽略
cd test//不是必须如果打开原有项目可以忽略
1:git init 
2:git add .
3:git commit -m '描述说明'
4:npm run eject

 

posted @ 2020-08-18 13:38  少哨兵  阅读(295)  评论(0编辑  收藏  举报