简体   繁体   中英

React Native babel plugin errors

Error message 'index.js: Cannot use the decorators and decorators-legacy plugin together.

Looking at me devDependencies, seems like I only have one? Can anyone help please?

"devDependencies": {
  "@babel/core": "^7.8.3",
  "@babel/plugin-proposal-decorators": "^7.8.3",
  "@babel/preset-flow": "^7.8.3",
  "@babel/runtime": "^7.8.3",
  "babel-preset-react-app": "^9.1.0",
  "@react-native-community/eslint-config": "^0.0.6",
  "babel-jest": "^24.9.0",
  "eslint": "^6.8.0",
  "jest": "^24.9.0",
  "metro-react-native-babel-preset": "^0.56.4",
  "react-test-renderer": "16.9.0"
},
"jest": {
  "preset": "react-native"
},
"babel": {
  "presets": [
    "react-app"
  ],
  "plugins": [
    [
      "@babel/plugin-proposal-decorators",
      {
        "legacy": true
      }
    ]
  ]
}

babel.config.js

module.exports = {
  presets: [
    "module:metro-react-native-babel-preset",
    "react-native",
    "@babel/preset-flow"
  ],
};

To replicate the comment that answered your problem;

Make sure to have only one babel config that is either in the babel.config.js , or directly within the package.json file. Otherwise there might be conflicts between the two different configs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM