简体   繁体   中英

How to fix 'Module build failed: SyntaxError: Missing class properties transform.'?

In my reactjs component I have this code:

increment = () => {
     store.dispatch({type: 'INC'});
}

When I run npm start in the console I get:

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 :

  "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 . I removed the redundant options from my webpack.config and now it runs.

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