今天入坑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
如果有更好的方法请留言,大家互相学习
网友评论