javascript - "loose": true is not fixing Support for the experimental syntax 'classProperties' isn't currently enabled

标签 javascript node.js express npm

Support for the experimental syntax 'classProperties' isn't currently enabled

我尝试了解决方案,重新构建后仍然出现错误。

Support for the experimental syntax 'classProperties' isn't currently enabled

package.json

{
  "name": "blahmodule",
  "version": "1.0.0",
  "description": "a fetch module for our project",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "./node_modules/.bin/babel src --out-file index.js"
  },
  "peerDependencies": {
    "react": "^16.6.6",
    "react-dom": "^16.6.3",
    "axios": "^0.19.0"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@babel/cli": "^7.4.4",
    "@babel/core": "^7.4.5",
    "@babel/preset-env": "^7.4.5",
    "@babel/preset-react": "^7.0.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6"
  },
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.4.4",
    "axios": "^0.19.0"
  }
}

.babelrc

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

最佳答案

我正在使用 plugin-proposal-class-properties 并且它可以工作,这是我的 JSON 配置文件 .babelrc

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

关于javascript - "loose": true is not fixing Support for the experimental syntax 'classProperties' isn't currently enabled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56813044/

相关文章:

javascript - 为什么 Ionic 2 构建如此之大,即使对于小型/空白应用程序也是如此?

javascript - 尝试为图表制作动画

javascript - Facebook 和 google 如何随机化 html 选择器 id 和类名?

Javascript 按钮值不更新

java - 安卓、YUI、Moodle

linux - 无法访问亚马逊 AWS 托管的 nodeJs 项目

node.js - Node Js 响应

node.js - Cloudinary Node 包错误 - 意外的 token

node.js - Mongoose:使用其他模型的模式

java - 从 Node.js 应用程序调用 java 程序