Reputation: 12394
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",
...
Upvotes: 5
Views: 8419
Reputation: 995
Specify the version
at the plugin to support modern decorators, see docs for all versions.
[
"@babel/plugin-proposal-decorators",
{
"version": "2023-05"
}
]
Upvotes: 0
Reputation: 81
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
Upvotes: 1
Reputation: 12394
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
Upvotes: 2
Reputation: 7394
Try this. It worked for me
module.exports = {
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]]
};
Upvotes: 6