[英]How to fix 'Module build failed: SyntaxError: Missing class properties transform.'?
In my reactjs component I have this code: 在我的reactjs组件中,我有这样的代码:
increment = () => {
store.dispatch({type: 'INC'});
}
When I run npm start in the console I get: 当我在控制台中运行npm start时,我得到:
Module build failed: SyntaxError: Missing class properties transform.
I installed : 我安装了:
npm install --save-dev babel-plugin-transform-class-properties
And also added this to my .babelrc : 并将此添加到我的.babelrc:
"plugins": [
"transform-class-properties"
],
"presets": [
"es2015",
"react",
"stage-0"
],
How can I resolve this? 我该如何解决这个问题?
Have you seen this other post: Error: Missing class properties transform ? 你有没有看到这篇文章: 错误:缺少类属性转换 ?
I had a similar problem, and, as one of the comments on the accepted answer above suggests, I had the presets listed in both my .babelrc
file and my webpack.config
. 我遇到了类似的问题,并且,正如上面接受的答案中的一条评论所示,我在
.babelrc
文件和webpack.config
中都列出了预设。 I removed the redundant options from my webpack.config
and now it runs. 我从
webpack.config
删除了冗余选项,现在它运行了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.