Requires Babel “^7.0.0-0“, but was loaded with “6.26.3“. 报错解决

安装Babel到v7.0.0后,使用命令偶尔报错,原因是Babel核心和配置版本不匹配。作者因曾全局安装Babel6导致此问题,解决办法是先全局卸载Babel6,再更新核心到@^7.0.0,按需装插件。若有插件强制用Babel6,可安装babel-core@^7.0.0-bridge.0解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在安装babel到 v7.0.0之后,使用babel命令偶尔会出现如下错误:

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.

原因自然是因为babel核心和babel配置版本不匹配造成的。

而我自己因为以前全局安装过babel6,从而导致这个错误。

因此我先是全局卸载babel6,然后根据官网,更新babel核心 @babel/core @babel/cli 到 @^7.0.0 ,其余插件按需安装。


以下为搜索解决方案时查到的其余解决办法:

如果有其他插件强制使用了babel6,那么更新核心之后可能仍然无法解决问题,此时可以安装 babel-core@^7.0.0-bridge.0 解决。

npm i babel-core@7.0.0-bridge.0 -D

使用这种方法就不一定需要更新 @babel/cli 了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值