1

This is my app.js file:

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

export default App;

Here is my package.json file:

{
  "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
      }
    ]

  ]
}

And here is an error which I am facing:

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.

I tried every post which I was able to find on Stackoverflow or GitHub or many other places but still, I am facing this error. I tried to put a plugin in .babelrc file, and in bable-config.js. I would really appreciate if someone took some time to explain what causes the problem and how to resolve it.

Amin
  • 21
  • 1
  • 5

0 Answers0