1

这是我的app.js文件:

import React from "react";
const WhatsAppWeb = require("baileys"); //Only this line causing an error
function App() {
  return <h1>Hello</h1>;
}

export default App;

这是我的package.json文件:

{
  "name": "version4",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "baileys": "^1.1.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.10.1",
    "babel-plugin-transform-class-properties": "^6.24.1"
  },
  "plugins": [
    [
      "@babel/plugin-proposal-class-properties",
      {
        "loose": true
      }
    ]

  ]
}

这是我面临的一个错误:

SyntaxError: C:\Nexus berry\Web\For-Future-purpose\version4\node_modules\baileys\WhatsAppWeb.js: Support for the experimental syntax 'classProperties' isn't currently enabled (21:18):

  19 |   * set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send
  20 |   */
> 21 |  static Presence = {
     |                  ^
  22 |          available: "available", // "online"
  23 |          unavailable: "unavailable", // "offline"
  24 |          composing: "composing", // "typing..."

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.

我尝试了可以​​在 Stackoverflow 或 GitHub 或许多其他地方找到的每一篇文章,但我仍然面临这个错误。我试图将插件放在.babelrc文件中,然后在bable-config.js. 如果有人花一些时间来解释导致问题的原因以及如何解决它,我将不胜感激。

4

0 回答 0