美文网首页React.jsReact 学习
关于create-react-app中间的坑

关于create-react-app中间的坑

作者: fred_33c7 | 来源:发表于2019-04-02 14:47 被阅读1次

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

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

相关文章

网友评论

    本文标题:关于create-react-app中间的坑

    本文链接:https://www.haomeiwen.com/subject/gflgbqtx.html