Uniswap / web3-react

A simple, maximally extensible, dependency minimized framework for building modern Ethereum dApps
https://web3-react-mu.vercel.app/
GNU General Public License v3.0
5.48k stars 1.51k forks source link

Module parse failed: Unexpected token walletconnect-v2 #902

Open MHarisAshfaq opened 7 months ago

MHarisAshfaq commented 7 months ago

Node Version is v14.21.2

This is my package.json file:

  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^13.0.0",
    "@testing-library/user-event": "^13.2.1",
    "@types/jest": "^27.0.1",
    "@types/node": "^16.7.13",
    "@types/react": "^17.0.0",
    "@types/react-dom": "^17.0.0",
    "@web3-react/core": "^8.2.3",
    "@web3-react/types": "^8.2.3",
    "@web3-react/walletconnect-v2": "^8.5.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "typescript": "^4.4.2",
    "web-vitals": "^2.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

And this is the error I am facing

Failed to compile.

./node_modules/@walletconnect/ethereum-provider/dist/index.es.js 55:10
Module parse failed: Unexpected token (55:10)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|       } : {})
|     },
>     r = e?.filter(l => !m.includes(l)),
|     d = i?.filter(l => !u.includes(l));
|   if (!s && !h && !n && !(r != null && r.length) && !(d != null && d.length)) return {

This error show up when I run npm/yarn start

Johnathon332 commented 4 months ago

I see that you are using Create React App, I ended up using Craco and added the appropriate babel loaders such as optional chaining and null coalescing.