简体   繁体   English

反应原生变换 - 错误找不到预设“babel-preset-react-native-stage-0

[英]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中给出的几乎所有可能的修复

  1. uninstalling latest version of babel-preset-react-native and re-installing sudo yarn add babel-preset-react-native@2.1.0 卸载最新版本的babel-preset-react-native并重新安装sudo yarn add babel-preset-react-native@2.1.0
  2. Clear cache Yarn Cache, npm cache 清除缓存Yarn Cache,npm缓存
  3. deleting build folder, deleting npm modules and reinstall all modules 删除构建文件夹,删除npm模块并重新安装所有模块
  4. Few people fixed the issue by removing watchman, but I am not using watchman at all. 很少有人通过移除守望者来解决问题,但我根本不使用守望者。
  5. Adding .babelrc mentioning decorator-support for preset as follows, this fix also didn't work. 添加.babelrc提到装饰器支持预设如下,此修复也无法正常工作。

.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: 尝试:

  1. $ cd your_project $ cd your_project
  2. $ nano .babelrc (Or any editor that you wants) $ nano .babelrc (或者你想要的任何编辑器)
  3. Copy and paste #A 复制并粘贴#A

If you didn't have .babelrc in your project, then: 如果您的项目中没有.babelrc,那么:

  1. $ cd your_project
  2. touch .babelrc
  3. copy and paste #A 复制并粘贴#A

#A #一种

{
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": ["transform-react-jsx-source"]
    }
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 捆绑失败:错误:找不到模块“ babel-preset-react-native-stage-0 / decorator-support” - bundling failed: Error: Cannot find module 'babel-preset-react-native-stage-0/decorator-support' 错误:捆绑失败:错误:找不到相对于目录“ C:\\\\ Users \\\\…”的预设“ module:metro-react-native-babel-preset” - error: bundling failed: Error: Couldn't find preset “module:metro-react-native-babel-preset” relative to directory “C:\\Users\\…” React-Native 0.57:'找不到变量:require'with metro-react-native-babel-preset - React-Native 0.57: 'Can't find variable: require' with metro-react-native-babel-preset React-Native错误:找不到模块“ metro-react-native-babel-preset” - React-Native error: cannot find module 'metro-react-native-babel-preset' 适用于Android的React Native-使用./gradlew assembleRelease将产生“找不到模块'babel-preset-react-app'”错误 - React Native for Android - Using ./gradlew assembleRelease will produce “Cannot find module 'babel-preset-react-app' “ error 捆绑失败:错误:无法从'/ workspace / reactnative找到模块'babel-preset-react-native' - bundling failed: Error: Cannot find module 'babel-preset-react-native' from '/workspace/reactnative'' 错误:找不到相对于目录的预设“ react-hmre” - Error: Couldn't find preset “react-hmre” relative to directory 找不到预设“@ babel / env” - reactjs - Couldn't find preset “@babel/env” - reactjs React:找不到相对于目录“src”的预设“env react” - React: Couldn't find preset “env react” relative to directory “src” 为什么在ReactJS for React Hot Loader中出现“错误:找不到相对于目录的预设“反应热”…”? - Why the 'Error: Couldn't find preset “react-hot” relative to directory…" in ReactJS for React Hot Loader?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM