![](/img/trans.png)
[英]How to Resolve Failed to load config “prettier” to extend from. in react Js
[英]eslint Failed to load config "react-app" to extend from. when making changes in project
我使用yarn create react-app
創建了一個反應應用程序。 然后我運行yarn start
並且項目在 localhost 上正常運行。 但是,當我對文件進行編輯(添加新標簽,重命名 div 的內容..)時,應用程序會引發錯誤並且無法編譯並出現錯誤
[eslint] 無法加載配置“react-app”以擴展。
已經安裝了 Eslint。 瘋狂的是,打開 package.json 文件並保存它可以解決問題,並且項目可以使用新的更改進行編譯。 但是,每次我做出改變時,我都必須這樣做。
我在 WSL 上使用 Ubuntu。
這是我的 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" ] } }
解決問題的幾種方法:
添加 eslint-config-react-app
yarn add eslint-config-react-app -D
或yarn add eslint-config-react -D
從 package.json 中刪除此代碼
"extends": [
"react-app"
]
},
我有一個類似的問題,我通過安裝eslint-config-react-app
解決了它:
yarn add eslint-config-react-app -D
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.