Javascript ES6 TypeError: Class constructor Client cannot be invoked without 'new'

后端 未结 6 709
深忆病人
深忆病人 2020-11-30 02:59

I have a class written in Javascript ES6. When I try to execute nodemon command I always see this error TypeError: Class constructor Client cannot be invo

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 03:36

    In package.json you can use targets configuration with @babel/preset-env. set the esmodules as 'true'.

    Below is the example how I am using in my file:

      "babel": {
        "presets": [
          [
            "@babel/preset-env",
            {
              "targets": {
                "esmodules": true
              }
            }
          ],
          "@babel/preset-react",
          "@babel/preset-flow"
        ],
        "plugins": [
          "@babel/plugin-proposal-class-properties"
        ]
      },
    

提交回复
热议问题