React.jsReact 学习

关于create-react-app中间的坑

2019-04-02  本文已影响1人  fred_33c7

今天入坑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

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

上一篇下一篇

猜你喜欢

热点阅读