首页 文章

尝试安装MobX但在启动服务器时出现装饰器错误

提问于
浏览
0

当我安装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'.

现在我已经弹出了依赖项并安装了decorator-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"
}

任何帮助将不胜感激,因为这在过去几天一直让我疯狂 .

1 回答

  • 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"
    }
    

相关问题