简体   繁体   中英

Add plugin-proposal-class-properties to create-react-app project

I created a react project using create-react-app . Now when I add a certain dependency in package.json I get an error after running 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.

I tried to use npm run eject and then do npm install --save-dev @babel/plugin-proposal-class-properties but that is not working even if I update the babel part in the package.json with:

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

What am I missing? I tried the solutions already proposed in this forum but they are not working. Thanks

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM