简体   繁体   English

eslint 无法加载要扩展的配置“react-app”。 在项目中进行更改时

[英]eslint Failed to load config "react-app" to extend from. when making changes in project

I created a react app using yarn create react-app .我使用yarn create react-app创建了一个反应应用程序。 Then I run yarn start and the project run properly on localhost.然后我运行yarn start并且项目在 localhost 上正常运行。 However, when I make an edit to a file (add a new tag, rename contents of a div..) the app throws an error and fails to compile with the error但是,当我对文件进行编辑(添加新标签,重命名 div 的内容..)时,应用程序会引发错误并且无法编译并出现错误

[eslint] Failed to load config "react-app" to extend from. [eslint] 无法加载配置“react-app”以扩展。

Eslint is already installed.已经安装了 Eslint。 The crazy thing is, opening the package.json file and saving it solves the issue and the project compiles with the new changes.疯狂的是,打开 package.json 文件并保存它可以解决问题,并且项目可以使用新的更改进行编译。 However I'd have to do this every time I make a change.但是,每次我做出改变时,我都必须这样做。

I am using Ubuntu on WSL.我在 WSL 上使用 Ubuntu。

Here is my package.json file这是我的 package.json 文件

 { "name": "gmail-clone", "version": "0.1.0", "private": true, "dependencies": { "@reduxjs/toolkit": "^1.8.1", "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.0.1", "@testing-library/user-event": "^14.1.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-redux": "^8.0.1", "react-scripts": "5.0.1", "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" ] } }

A few ways to solve the issues:解决问题的几种方法:

  1. Add the eslint-config-react-app添加 eslint-config-react-app

    yarn add eslint-config-react-app -D OR yarn add eslint-config-react -D yarn add eslint-config-react-app -Dyarn add eslint-config-react -D

  2. Remove this code from package.json从 package.json 中删除此代码

"extends": [
         "react-app"
       ]
     },
  1. Remove yarn.lock and reinstall node modules.删除 yarn.lock 并重新安装节点模块。

I had a similar problem, and I resolved it by installing eslint-config-react-app :我有一个类似的问题,我通过安装eslint-config-react-app解决了它:

yarn add eslint-config-react-app -D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决无法加载配置“更漂亮”以进行扩展。 在反应 Js - How to Resolve Failed to load config “prettier” to extend from. in react Js ESLint 错误 - ESLint 找不到配置“react-app” - ESLint error - ESLint couldn't find the config "react-app" 语法错误:错误:无法加载要扩展的配置“ckeditor5”。 将 CKEditor 导入 Vuejs 时 - Syntax Error: Error: Failed to load config “ckeditor5” to extend from. While importing CKEditor to Vuejs ESLint:无法加载配置“next/babel”以扩展 - ESLint: Failed to load config "next/babel" to extend from 无法加载配置“react”以从 - Failed to load config "react" to extend from 无法加载配置“更漂亮”以从 - Failed to load config "prettier" to extend from 无法加载在 'package.json » eslint-config-react-app#overrides[0]' 中声明的解析器 '@typescript-eslint/parser':找不到模块 'typescript' - Failed to load parser '@typescript-eslint/parser' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript' 创建 React 应用程序失败。 我使用了 npm init react-app my-app - Creating React app failed. I used npm init react-app my-app 如何扩展 Eslint 以使用 create-react-app - How to Extend Eslint to work with create-react-app 扩展 eslint-config-react-app 时 no-use-before-define 无效 - no-use-before-define has no effect when extending eslint-config-react-app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM