bundling failed: Error: Cannot find module 'babel-preset-react-native-stage-0/decorator-support'

14,598

Solution 1

I too was getting the same problem while I was trying to run an old react-native project. I am just starting to learn react-native and hence was experimenting with an old project from a colleague.

After reading above answers I finally solved this issue

There were lot of files in the root folder of which two were:

  1. .babelrc
  2. babel.config.js

containing following things:

.babelrc

{ 
 "presets": ["react-native"]
}

babel.config.js

module.exports = {
 presets: ['module:metro-react-native-babel-preset'],
};

I didn't knew either of them. But I tried following above answers and commented out .babelrc contents like this:

{ 
 // "presets": ["react-native"]
}

Then started the server again and it did run as expected.

Solution 2

For me I solved the Issue to remove the second preset:

"presets": [
            "react-native"
          ]

down in the "plugins"-Section:

{
  "presets": ["module:metro-react-native-babel-preset"],
  "env": {
    "production": {
      "plugins": [
        "transform-remove-console",
        "@babel/plugin-proposal-optional-chaining",
        [
          "module-resolver",
          {
            "root": [
              "./src"
            ],
            "alias": {
              "test": "./test",
              "components": "./components",
              "config": "./config",
              "lib": "./lib"
            }
          }
        ]
      ],
      "presets": [
        "react-native"
      ]
    }
  }
}

Maybe it helps somebody.

Share:
14,598
151291
Author by

151291

Updated on July 26, 2022

Comments

  • 151291
    151291 almost 2 years

    Getting this error after push and clone from bitbucket, previously existing project running fine, after clone from bitbucket did npm install and .babelrc file exist in the root directory.

    {
      "presets": [
        "babel-preset-react-native-stage-0/decorator-support"
      ],
      "env": {
        "development": {
          "plugins": [
            "transform-react-jsx-source"
          ]
        }
      }
    }
    

    Steps tried :

    • npm install babel-preset-react-native-stage-0 --save
    • npm install --save-dev [email protected]

    But getting same error on the screen.

    Screen shot :

    enter image description here

  • Limitless Claver
    Limitless Claver about 4 years
    I had a similar issue, I just tried your method and it worked for me.