【问题标题】:again and again this error, i can't solve it when running react app一次又一次出现这个错误,运行react app时无法解决
【发布时间】:2021-08-23 04:17:12
【问题描述】:

编译失败 ./src/index.js 1:39 模块解析失败:意外令牌 (1:39) 使用这些加载器处理了文件:

  • ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
  • ./node_modules/babel-loader/lib/index.js 您可能需要额外的加载器来处理这些加载器的结果。

$RefreshRuntime$ = require('C:/Users/I'm-cx0140/Desktop/myapp/node_modules/react-refresh/runtime.js'); | $RefreshSetup$(module.id); | 此错误发生在构建期间,无法消除。

我的 package.json 文件

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.13.0",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.2"
  },
  "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"
    ]
  }
}

enter code here

【问题讨论】:

  • 您是否尝试过删除节点模块文件夹并重做npm install

标签: reactjs


【解决方案1】:

尝试降级 react 脚本-

进入 package.json 并更改 react-scripts to 4.0.1 并输入 npm install(terminal) 并重新运行它。

【讨论】:

  • 我也用 react-scripts 4.0.1 和 4.0.2 试过了,但没有用
  • @Harikrushnachavada 检查您如何命名文件夹。它不应包含任何空格或 ( ' )。
  • 我听不懂你在说什么?我应该怎么做才能修复这个错误
  • I'm-cx0140 中的 ( ' ) 尝试将其替换为 Im-cx0140
猜你喜欢
  • 2020-01-10
  • 1970-01-01
  • 2013-04-27
  • 1970-01-01
  • 2017-08-21
  • 2022-11-09
  • 2011-03-31
  • 1970-01-01
  • 2015-10-16
相关资源
最近更新 更多