[英]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:解决问题的几种方法:
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 -D
或yarn add eslint-config-react -D
Remove this code from package.json从 package.json 中删除此代码
"extends": [
"react-app"
]
},
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.