反应本机转换-错误找不到预设的"babel-preset-react-native-stage-0" [英] react native transform - error couldn't find preset "babel-preset-react-native-stage-0
问题描述
我开始退出博览会,经过这么多努力,我能够解决所有建筑问题. 当我使用'sudo react-native run-android'运行应用程序时,我开始出现以下错误
I started ejecting expo, after so much struggle I could able to solve all build issues. When I run the app using 'sudo react-native run-android' I started getting following error
错误:
The development server returned response code 500
Bundling `index.android.js` [development, non-minified, hmr disabled]
0.0% (0/1), failed.
error: bundling failed: "TransformError:
/Development/SourceCode/MobileApp/index.android.js:
Couldn't find preset \"babel-preset-react-native-stage-0/decorator-support\" relative to directory \"/Development/SourceCode/MobileApp\""
我尝试了github和SO中给出的几乎所有可能的修复程序
I tried almost all possible fixes given in github and SO
- 卸载最新版本的babel-preset-react-native并重新安装sudo yarn添加babel-preset-react-native@2.1.0
- 清除缓存纱线缓存,npm缓存
- 删除构建文件夹,删除npm模块并重新安装所有模块
- 很少有人通过删除值班员来解决此问题,但我根本没有使用值班员.
- 添加.babelrc提及对预置的装饰器支持,如下所示,此修复也无效.
.babelrc
文件如下所示:
.babelrc
file looks like this
{
"presets": [
"react-native",
"babel-preset-react-native-stage-0/decorator-support"
],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source"
]
}
}
}
这些修补程序都没有对我有用.使用babel-preset-react-native@2.1.0
并不能解决问题,因为这是主要的解决方法.
None of those fixes worked for me. using babel-preset-react-native@2.1.0
also didn't fix the issue because that was the major fix.
推荐答案
尝试按以下方式使用常规babel预设0: https://babeljs.io/docs/plugins/preset-stage-0
Try to use normal babel preset 0 as per: https://babeljs.io/docs/plugins/preset-stage-0
如此
"presets": ["react-native", "stage-0"]
这篇关于反应本机转换-错误找不到预设的"babel-preset-react-native-stage-0"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!