当我安装Mobx并且Mobx反应时,出现以下错误。
./src/index.js
Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option,
whose value must be a boolean. If you are migrating from Babylon/Babel 6 or
want to use the old decorators proposal, you should use the 'decorators-legacy'
plugin instead of 'decorators'.
现在,我弹出了依赖项,并安装了decorators-legacy作为插件。这就是我的package.json文件中的内容
"babel": {
"plugins": [
"transform-decorators-legacy"
],
"presets": [
"react-app"
]
},
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.1.2",
"babel-plugin-transform-decorators-legacy": "^1.3.5"
}
任何帮助将不胜感激,因为这在最近几天一直使我发疯。
答案 0 :(得分:0)
在Tholle撰写文章时,链接非常有帮助。我的配置在我的package.json中。
"babel": {
"presets": ["@babel/preset-env","react-app"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
},
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.1.2",
"babel-plugin-transform-decorators-legacy": "^1.3.5"
}