关于create-react-app中间的坑

今天入坑react,在用脚手架creat-react-app新建一个项目时,发现时不时报错:

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.28.3"

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/admin/node_modules/webpack (version: 4.29.6) 

这种错误,这是因为你系统中的node_modules中的包版本和项目中的包版本不同,解决办法:将系统中的包删除,安装react需要的包版本

例如:react中webpack是4.28.3
在系统中 npm uninstall webpack然后,npm install webpack@4.28.3就可以避免这个error

如果有更好的方法请留言,大家互相学习

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容