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即可