【发布时间】: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