yarn run eject时
Remove untracked files, stash or commit any changes, and try again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! devportalfrontend@0.1.0 eject: `react-scripts eject`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the devportalfrontend@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! /home/deep/.npm/_logs/2018-02-18T17_05_02_924Z-debug.log
Uninstalling react-scripts and installing react-scripts-cssmodules solved the problem
npm uninstall react-scripts
npm install react-scripts-cssmodules
npm run eject
运行第一个命令时报错,权限错误,关闭后用管理员模式打开运行
git add .
git commit -am "Save before ejecting"
成功
代码问题
1.图片img路径问题



运行报错

require后的()中接收的是string类型,可能state保存的是object类型
解决方法:将require一起存入state中
handleOpen=(img)=>{
this.setState({
visible:true,
currentImg:require('../../resource/assets/img/gallery/'+img),
})
}
4.commit时报错

解决:删除.git里的pre-commit文件,不是万全之策,尝试其他解决办法
网友评论