【问题标题】:Add plugin-proposal-class-properties to create-react-app project将 plugin-proposal-class-properties 添加到 create-react-app 项目
【发布时间】:2021-02-13 22:48:23
【问题描述】:

我使用create-react-app 创建了一个反应项目。 现在,当我在package.json 中添加某个依赖项时,运行npm start 后出现错误:

Support for the experimental syntax 'classProperties' isn't currently enabled.
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.

我尝试使用npm run eject,然后使用npm install --save-dev @babel/plugin-proposal-class-properties,但即使我将package.json 中的babel 部分更新为:

"babel": {
    "presets": [
      "react-app"
    ],
    "plugins": [
      "@babel/plugin-proposal-class-properties"
    ]
}

我错过了什么?我尝试了该论坛中已经提出的解决方案,但它们不起作用。谢谢

【问题讨论】:

    标签: reactjs webpack babeljs create-react-app package.json


    【解决方案1】:

    你可以使用 react-app-rewired 来覆盖 webpack。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-01
      • 2022-08-15
      • 1970-01-01
      • 2019-05-16
      • 2019-02-16
      • 2020-11-01
      • 1970-01-01
      相关资源
      最近更新 更多