How to fix "Failed to compile. ./node_modules/plyr/dist/plyr.min.js 1947:29"

242 Views Asked by At
Failed to compile.

./node_modules/plyr/dist/plyr.min.js 1947:29
Module parse failed: Unexpected token (1947:29)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|         let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
|         if (e ? _this2.scrollPosition = {
>           x: window.scrollX ?? 0,
|           y: window.scrollY ?? 0
|         } : window.scrollTo(_this2.scrollPosition.x, _this2.scrollPosition.y), document.body.style.overflow = e ? "hidden" : "", R(_this2.target, _this2.player.config.classNames.fullscreen.fallback, e), M.isIos) {

When i run my projuct "npm start", then this error is coming, i tried delete "node_modules" and installed "npm install" but still getting this error, can any one please help me.

My react version is: 18.0.0 Node: v16.13.0 Npm v: 8.1.0

2

There are 2 best solutions below

1
Maulik Patel On

Step-1: Run the following command to clear the npm cache:

npm cache clean --force

Step-2: Delete the "package-lock.json" file from your project directory.

Step-3: Reinstall dependencies by running following command:

npm install
6
monim On

Update your tsconfig.json file . and make sure the target property is set to ES5 :

"compilerOptions": {
    "target": "es5", //this line 
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],

And make sure the jsx property is set to react-jsx : "jsx": "react-jsx"

NOTE : make sure you're using latest version of react-scripts(v5)