4

I am getting the following Babel error

The decorators Plugin when .version is '2018-09' or not specified, requires a 'decoratorsBeforeExport' option, whose value must be a boolean. ..../node_modules/@babel/plugin-proposal-decorators/lib/index.js$inerhits

This is my babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    'react-native-reanimated/plugin',
    [
        "@babel/plugin-proposal-decorators", 
        { 
            "legacy": true, 
            "decoratorsBeforeExport": false // I tried this with true as well -> no luck either
        }
    ]
 ]
};

This are the versions I am using

    ....
"dependencies": {
    "react": "17.0.2",
    "react-native": "0.66.4"
    ...

"devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/plugin-proposal-decorators": "^7.17.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    ...
four-eyes
  • 10,740
  • 29
  • 111
  • 220

3 Answers3

4

Try this. It worked for me

module.exports = {
    presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
    plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]]

};

Indra Basak
  • 7,124
  • 1
  • 26
  • 45
1

Make sure to re-run your project when you add these lines. Hot reloading won't work here. Also, it's good to run $ watchman watch-del-all and npm start -- --reset-cache

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
four-eyes
  • 10,740
  • 29
  • 111
  • 220
0

That error used to be related to an issue on how you installed your '@babel/plugin-proposal-decorators'. Try to reinstall it as a regular dependency, not dev dependency.

More information here: https://github.com/electron-userland/electron-webpack/issues/251#issuecomment-504693323

borchvm
  • 3,533
  • 16
  • 44
  • 45
Yuri Silva
  • 49
  • 9