解决create-react-app脚手架创建的项目中按需引入ant-design时 报错TypeError: injectBabelPlugin is not a function的问题

版权声明:Dream_Lees Blog https://blog.csdn.net/qq_41846861/article/details/86561674

React:create-react-app脚手架项目中按需引入ant-design报错TypeError: injectBabelPlugin is not a function

错误形式

运行npm start时报如下错误:
TypeError: injectBabelPlugin is not a function
如下图:
在这里插入图片描述

错误原因

应该是react-scripts 升级到 2.1.2 以后破坏了 react-app-rewired

解决办法

对react-scripts进行降级处理

// 在terminal输入下列命令
npm install react-app-rewired@2.0.2-next.0

如图:
在这里插入图片描述
完成后在再输入命令npm start就可以正常运行项目了。

猜你喜欢

转载自blog.csdn.net/qq_41846861/article/details/86561674