reactjs 如何修复“无法编译,./node_modules/plyr/dist/plyr.min.js 1947:29”

mwg9r5ms  于 2023-05-28  发布在  React
关注(0)|答案(2)|浏览(408)
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) {

当我运行我的项目“npm start”,然后这个错误来了,我试图删除“node_modules”并安装“npm install”,但仍然得到这个错误,可以任何一个请帮助我。
我的react版本是:18.0.0节点:v16.13.0 Npm v:8.1.0

5lhxktic

5lhxktic1#

**Step-1:**执行以下命令清空npm缓存:

npm cache clean --force

**Step-2:**从项目目录中删除package-lock.json文件。
**第三步:**执行以下命令重新安装依赖:

npm install
uklbhaso

uklbhaso2#

更新tsconfig.json文件。并确保target属性设置为ES5

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

并确保jsx属性设置为react-jsx"jsx": "react-jsx"

**注意:**确保您使用的是最新版本的react-scripts(v5)

相关问题