【问题标题】:eslint failed to load config "react-app" to extend fromeslint 无法加载配置“react-app”以从
【发布时间】:2022-08-10 12:06:35
【问题描述】:

我之前遇到过 eslint 的一个奇怪问题,我不得不卸载 node_modules 并执行 npm install ,自从我这样做后,我的代码中出现了我以前从未遇到过的新错误。我无法完全弄清楚如何解决的一个错误就是这个。

ERROR in [eslint] Failed to load config \"react-app\" to extend from.
Referenced from: C:\\Users\\Justi\\Downloads\\package.json

这是我的 package.json 文件夹:

{
  \"name\": \"gingerrmarket\",
  \"version\": \"0.1.0\",
  \"private\": true,
  \"dependencies\": {
    \"@emotion/react\": \"^11.5.0\",
    \"@emotion/styled\": \"^11.3.0\",
    \"@fortawesome/free-solid-svg-icons\": \"^5.15.4\",
    \"@fortawesome/react-fontawesome\": \"^0.1.16\",
    \"@material-ui/core\": \"^4.12.3\",
    \"@material-ui/icons\": \"^4.11.2\",
    \"@mui/icons-material\": \"^5.0.4\",
    \"@mui/material\": \"^5.1.0\",
    \"@testing-library/jest-dom\": \"^5.14.1\",
    \"@testing-library/react\": \"^11.2.7\",
    \"@testing-library/user-event\": \"^12.8.3\",
    \"firebase\": \"^9.4.1\",
    \"react\": \"^17.0.2\",
    \"react-dom\": \"^17.0.2\",
    \"react-feather\": \"^2.0.9\",
    \"react-router-dom\": \"^6.0.0\",
    \"react-scripts\": \"^5.0.1\",
    \"web-vitals\": \"^1.1.2\"
  },
  \"scripts\": {
    \"start\": \"react-scripts start\",
    \"build\": \"react-scripts build\",
    \"test\": \"react-scripts test\",
    \"eject\": \"react-scripts eject\"
  },
  \"browserslist\": {
    \"production\": [
      \">0.2%\",
      \"not dead\",
      \"not op_mini all\"
    ],
    \"development\": [
      \"last 1 chrome version\",
      \"last 1 firefox version\",
      \"last 1 safari version\"
    ]
  }
}

这是我在 babel 中的 eslint 解析器文件(我不确定它是否有用。)

   \"name\": \"@babel/eslint-parser\",
  \"version\": \"7.18.2\",
  \"description\": \"ESLint parser that allows for linting of experimental syntax transformed by Babel\",
  \"author\": \"The Babel Team (https://babel.dev/team)\",
  \"license\": \"MIT\",
  \"repository\": {
    \"type\": \"git\",
    \"url\": \"https://github.com/babel/babel.git\",
    \"directory\": \"eslint/babel-eslint-parser\"
  },
  \"publishConfig\": {
    \"access\": \"public\"
  },
  \"bugs\": {
    \"url\": \"https://github.com/babel/babel/issues\"
  },
  \"homepage\": \"https://babel.dev/\",
  \"engines\": {
    \"node\": \"^10.13.0 || ^12.13.0 || >=14.0.0\"
  },
  \"main\": \"./lib/index.cjs\",
  \"type\": \"commonjs\",
  \"exports\": {
    \".\": \"./lib/index.cjs\",
    \"./experimental-worker\": \"./lib/experimental-worker.cjs\",
    \"./package.json\": \"./package.json\"
  },
  \"peerDependencies\": {
    \"@babel/core\": \">=7.11.0\",
    \"eslint\": \"^7.5.0 || ^8.0.0\"
  },
  \"dependencies\": {
    \"eslint-scope\": \"^5.1.1\",
    \"eslint-visitor-keys\": \"^2.1.0\",
    \"semver\": \"^6.3.0\"
  },
  \"devDependencies\": {
    \"@babel/core\": \"^7.18.2\",
    \"dedent\": \"^0.7.0\",
    \"eslint\": \"^7.27.0\",
    \"eslint-8\": \"npm:eslint@^8.0.0\"
  }
}

有没有人有什么建议?请帮忙。

  • 从您共享的代码中,我根本看不到它在哪里扩展了“react-app”。你有 eslintrc 配置文件吗?可能命名为.eslintrc.js.eslintrc.json
  • @spencer.sm 我没有 .eslintrc.js 文件或 eslintrc.json 文件,但我想在 react.json 中扩展它。我该怎么做?

标签: reactjs eslint create-react-app package.json autoprefixer


【解决方案1】:

你试过运行npm i eslint-config-react-app -D 了吗?

【讨论】:

  • 刚做了这个。没用。
【解决方案2】:

为此,所需要的只是

"eslintConfig": { "extends": [ "react-app", "react-app/jest" ] },

在 package.json

【讨论】:

    【解决方案3】:

    我遇到了同样的问题,但下面的代码已经附加。谁能告诉另一种解决这个问题的方法

    “eslintConfig”:{ “扩展”:[ “反应应用程序”, “反应应用程序/笑话” ]

    【讨论】:

      猜你喜欢
      • 2021-10-11
      • 1970-01-01
      • 2021-01-02
      • 2022-01-07
      • 1970-01-01
      • 2017-12-04
      • 2021-04-20
      • 2019-11-13
      • 2022-01-04
      相关资源
      最近更新 更多