我开始退出世博会,经过如此多的努力,我能够解决所有构建问题。 当我使用“sudo react-native run-android”运行应用程序时,我开始出现以下错误
错误:
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 中给出的几乎所有可能的修复
- 卸载最新版本的 babel-preset-react-native 并重新安装 sudo yarn add babel-preset-react-native@2.1.0
- 清除缓存 Yarn 缓存、npm 缓存
- 删除构建文件夹,删除 npm 模块并重新安装所有模块
- 很少有人通过删除 watchman 来解决这个问题,但我根本不使用 watchman。
- 添加 .babelrc 并提及对预设的装饰器支持,如下所示,此修复也不起作用。
.babelrc
文件看起来像这样
{
"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 也没有解决问题,因为这是主要的修复。
最佳答案
尝试使用正常的 babel 预设 0,如下所示:https://babeljs.io/docs/plugins/preset-stage-0
所以
"presets": ["react-native", "stage-0"]
关于reactjs - react native 转换 - 错误找不到预设“babel-preset-react-native-stage-0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50125294/