Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 316
151291 Avatar asked Sep 20 '18 06:09

151291


2 Answers

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.

like image 126
ibaggu Avatar answered Nov 01 '22 16:11

ibaggu


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.

like image 1
suther Avatar answered Nov 01 '22 16:11

suther