react脚手架构建运行时报错问题及解决
react脚手架构建运行时报错
具体操作
sudo npm install -g create-react-app mkdir react-first-demo cd react-first-demo create-react-app react-cli cd react-cli npm install (依赖安装完以后执行npm start) npm start
错误
$ react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.The react-scripts package provided by Create React App requires a dependency:
“webpack”: “4.29.6”
Don’t try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:/Users/mac/Desktop/node_modules/webpack (version: 3.8.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
…
解决方法
- 在react-cli项目里面添加.env文件,文件中添加SKIP_PREFLIGHT_CHECK=true,在运行npm start。
- 错误提示里又说这样可以解决目前问题,可能还会出现其他问题,暂时没遇到,有问题可以交流,或者有什么更好的方法。
结果


总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
使用react在修改state中的数组和对象数据的时候(setState)
这篇文章主要介绍了使用react在修改state中的数组和对象数据的时候(setState),具有很好的参考价值,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2022-09-09
解析TypeError:import_react_native.AppState.removeEventListener
这篇文章主要为大家介绍了TypeError:import_react_native.AppState.removeEventListener is not a function问题解决分析,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2023-09-09
简析React Native startReactApplication 方法
这篇文章主要介绍了React Native startReactApplication 方法简析,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2021-09-09


最新评论