启动react项目报错

启动react项目时,出现下面错误:
Error: The “injectBabelPlugin” helper has been deprecated as of v2.0. You can us
e customize-cra plugins in replacement - https://github.com/arackaf/customize-cr
a#available-plugins
at deprecate (E:\Vue\gzhipin-client\node_modules\[4mreact-app-rewired[24m
index.js:4:9)
at injectBabelPlugin (E:\Vue\gzhipin-client\node_modules\[4mreact-app-rewired[24m\index.js:18:12)
at Object.override [as webpack] (E:\Vue\gzhipin-client\config-overrides.js:3:14)
at Object. (E:\Vue\gzhipin-client\node_modules\[4mreact-app-rewired[24m\scripts\start.js:29:15)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gzhipin-client@0.1.0 start: react-app-rewired start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gzhipin-client@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache_logs\2020-09-11T0
7_14_12_081Z-debug.log
解决方法:
看到网上的说的可能是react-scripts包不全,需要npm install 或者npm install react-script重新安装,本人尝试了一下不好使
其实,仔细看上面的错误,可以发现:

Error: The "injectBabelPlugin" helper has been deprecated as of v2.0. You can us
e customize-cra plugins in replacement - https://github.com/arackaf/customize-cr
a#available-plugins

意思是:
自2.0版起,“injectbabelplugin”助手已被弃用
react-app-rewired的新版本删除了injectBabelPlugin,这些方法被移动到一个名为’customize-cra’的新包中
所以需要重新将react-script降低到2.0版本
首先卸载react-script

npm uninstall react-app-rewired

然后,重新安装react-script2.0版本:

npm i react-app-rewired@2.0.2-next.0

参考:https://blog.csdn.net/qq_43693520/article/details/93332415

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值