Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

  1. uninstalling latest version of babel-preset-react-native and re-installing sudo yarn add [email protected]
  2. Clear cache Yarn Cache, npm cache
  3. deleting build folder, deleting npm modules and reinstall all modules
  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 file looks like this

    {
      "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 [email protected] also didn't fix the issue because that was the major fix.

like image 857
Sadanand Avatar asked May 01 '18 23:05

Sadanand


1 Answers

Try to use normal babel preset 0 as per: https://babeljs.io/docs/plugins/preset-stage-0

so

"presets": ["react-native", "stage-0"]
like image 178
Ilja Avatar answered Oct 17 '22 21:10

Ilja