我使用 create-react-app
创建了一个React项目。
现在,在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"
]
}
我错过了什么?我在这个论坛上尝试了已经提出的解决方案,但它们都没有起作用。谢谢。