[英]react native transform - error couldn't find preset "babel-preset-react-native-stage-0
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
当我使用'sudo react-native run-android'运行应用程序时,我开始收到以下错误
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\""
I tried almost all possible fixes given in github and SO 我尝试了在github和SO中给出的几乎所有可能的修复
.babelrc
file looks like this .babelrc
文件看起来像这样
{
"presets": [
"react-native",
"babel-preset-react-native-stage-0/decorator-support"
],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source"
]
}
}
}
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-preset-react-native@2.1.0
也没有解决问题,因为这是主要修复。
Try to use normal babel preset 0 as per: https://babeljs.io/docs/plugins/preset-stage-0 尝试使用正常的babel预设0: https : //babeljs.io/docs/plugins/preset-stage-0
so 所以
"presets": ["react-native", "stage-0"]
You can create .babelrc file in root of you project with following content if you cany use old version of React Native: 如果您可以使用旧版本的React Native,可以使用以下内容在项目的根目录中创建.babelrc文件:
{
"presets": ["react-native"]
}
If you did use Expo in your project, 如果您在项目中使用了Expo,
try: 尝试:
cd your_project
cd your_project
nano .babelrc
(Or any editor that you wants) nano .babelrc
(或者你想要的任何编辑器) If you didn't have .babelrc in your project, then: 如果您的项目中没有.babelrc,那么:
$ cd your_project
touch .babelrc
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.