解决升级React Native0.57.7时报错问题: Couldn't find preset "module:metro-react-native-babel-preset"

ReactNative版本升级教程:https://reactnative.cn/docs/upgrading/

 

执行react-native-git-upgrade命令升级React Native0.57.7时可能出现的错误:An error occurred during upgrade: git-upgrade ERR! Error: Couldn't find preset "module:metro-react-native-babel-preset" relative to directory

An error occurred during upgrade: 
git-upgrade ERR! Error: Couldn't find preset "module:metro-react-native-babel-preset" relative to directory "/Users/semper/Documents/projects/latest/NovelAPP"
    at /usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-register/lib/node.js:103:45)
    at loader (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:566:32) 

解决办法:

将根目录下.bashrc文件内容:

{
  "presets": ["module:metro-react-native-babel-preset"]
}

改成

{
}

再执行 react-native-git-upgrade即可

 

以下是我的RN项目,如果对你有帮助,欢迎star:https://github.com/SemperChen/NovelAPP

 

演示视频:https://www.bilibili.com/video/av28309525/

截图

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值