create-react-app: ERROR in Plugin "react" was conflicted between ".eslintrc.json" and "BaseConfig"
After updating to CRA 5.0.0, I got this error on compilation process:
ERROR in Plugin "react" was conflicted between ".eslintrc.json" and "BaseConfig » "..\react-app\node_modules\eslint-config-react-app\base.js".
My eslint configuration is:
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"airbnb",
"plugin:react/jsx-runtime"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {...}
}
Any solutions/fixes?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 33
- Comments: 48
Commits related to this issue
- eslint bug fixed. See issue github.com/facebook/create-react-app/issues/11825 — committed to boahs/asciifishyfam by boahs 2 years ago
- fix: add workaround for ESLint BaseConfig conflict See https://github.com/facebook/create-react-app/issues/11825 — committed to stratego-chile/Smartblock-Site by KBeDevel 2 years ago
removing this from package.json worked for me:
“eslintConfig”: { “extends”: [ “react-app”, “react-app/jest” ] },
My team and I were able to solve this issue by re-installing all dependencies and removing
'react'from the list of plugins passed to our.eslintrc.Not sure why, but I removed my yarn.lock file (I use Yarn berry) then I reinstalled the dependencies using
yarnand the problem just disappearedWorkaround source
As strange as it may sound, for me the error happens when I switch from PowerShell to Git Bash. To fix it, I must run twice
npm start. First it will give me the error. I close the console, reopen it, tapnpm startagain and it works without errors.What I recently did and it works 100% is to create a new reat-app project (using CRA 5+), and move all the files and configurations inside that new folder.
So what I noticed. After upgrading the
react-scriptstheeslint-config-react-appfolder was created at the root level (./node_modules/eslint-config-react-app) and I have this error.After updating some eslint plugins and parsers
eslint-config-react-appmoved toreact-scriptsfolder (./node_modules/react-scripts/node_modules/eslint-config-react-app) and the error disappeared.I was unable to determine which dependency exactly caused this but there is a list of those that I updated. Maybe this will help.
I tried:
plugin:react/recommendedwasn’t being extendedFor now I’ve just had to preface
react-scripts startwithDISABLE_ESLINT_PLUGIN=trueUninstall Eslint extension from VScode if you have it. Then run npm uninstall -g eslint, then run npm install -g eslint, reinstall eslint extension in VScode, close your terminal/VsCode and reopen and try again it builds for me now.
This error indicates that there are 2 copies of
eslint-plugin-reactbeing fed into ESLint.I suspect that in my case the issue that
react-scriptsadds this plugin in the base config somewhere, but also I specifyin my
.eslintrcand I thinkreact/jsx-runtimealsoadds or useseslint-config-react-appandeslint-plugin-react`.This sometimes works fine, if there is only 1 copy of
eslint-plugin-reactin yournode_modulesdirectory (if they hoisted and are de-duplicated). Otherwise, eslint doesn’t know which one to use.If you are using Yarn modern (v2+) you can try to use
to try to diagnose if and why you have more than one copy of
eslint-plugin-reactDeleting
yarn.lockand generating a new one fixed it for me.Does anyone have a fix which would not affect the functionality? I know that we can get rid of the error by removing the plugins from the config but I don’t think the eslint is gonna behave the same right?
Btw so far we were not been able to update any of our 6 big projects (all yarn workspaces/mono repos) to CRA 5.0.0 everything is plagued by insane errors which comes mostly from the packages, weird incompatibilities and typescript build errors … Fixing one problem just lead to another and another… 😞
"extends": ["plugin:react/recommended", "prettier"],---->"extends": ["prettier"],["plugin:react/recommended" //removed"plugins": ["react", "react-hooks", "import", "prettier"],---->"plugins": ["react-hooks", "import", "prettier"],"react" //removedno problem 😉
For those still struggling with this and who have tried all the suggestions (like I had), explicitly stating the dependency in package.json with
resolutionsfixed it for me.Just in case, I solved it by removing all the
eslintrelated packages and installing them again, this time it downloaded the correct version.This should be the accepted answer.
I had the same problem (Win10, VSCode, npm, CRA + TS) and it was a casing mismatch, like some other people had as well. (
Dev/apps/my-app/instead ofDev/Apps/my-app/). It’s weird because I didn’t have that until a few days ago when opening back my project after almost 1 month away from it. Even before updating the deps.I solved this issue by upgrading dependencies like @aso1datov and @jpaholik did before me. Specifically, by upgrading the eslint-plugin-react dependency.
"eslint-plugin-react": "7.28.0"ERROR in [eslint] Plugin "react" was conflicted between "package.json » eslint-config-react-app » D:\github\react-demo\react-cli\node_modules\eslint-config-react-app\base.js" and "BaseConfig » D:\gitHub\react-demo\react-cli\node_modules\eslint-config-react-app\base.js"Will anyone solve this problem.
If you’re using CRA, you basically always have to eject to do anything meaningful, and this is the kind of issue you might see with react-scripts prior to ejecting.
I still experience this issue.
I am with the same problem, the funny thing is that when you save it from the package.json it executes the normal server but if I save it from a component it sends me the same error
I have the same problem.
I removed this from package.json:
And I added
reactfromeslint-plugin-reactto.eslintrc.jsonThis cause the following error
I removed followings from .eslintrc.json and it worked out;
I faced this issue today and resolved it by removing
caretfrom thereact-scriptsFrom
To
Below are the steps I followed to resolve that.
react-scriptsnode_modulesandpackage-lock.json/yarn.locknpm installoryarn installThis is the problem!
I override
eslint-plugin-reactusing yarn, inpackage.jsonwhen you install react-scripts, example last version such 5.0.1, its has dependencies with eslint-config-react-app => eslint-plugin-react and etc, so you don’t need install several packages what conflit with exist in node_module in other package also you can try remove dublicate from yarn.lock or package.lock: npm dedupe && npm i npx yarn-deduplicate && yarn yarn dedupe
i added it to my package.json and it worked as well thanks
I reproduce this same issue in my local. I fixed this issue by executing “npx eslint --init”.
This finally let me create a production build on my local using CRA. This issue was beyond frustrating - thanks for the suggestion.
Note: I went inside the Node_Modules directory =>
eslint dependency and removed the line in the code block quoted above.
I found a workaround\resolution for my particular case that I haven’t come across whilst googling so adding it here to see if it helps anyone else.
On Windows, I was launching VSCode from Powershell using the command
code .. Unfortunately, I had changed to my source directly by doing issuing acd c:\sourcecommand and then enteringcode ., rather than what the directory was actually called,cd c:\Source.Once I restarted VSCode after changing using the correct directory name and case, this issue that was being thrown by my React application disappeared!.
Apparently whilst the windows file system isn’t case sensitive, the application and coding environment that depends on it is.
Was having similar issues after updating react-scripts and many other packages in our project. Through pure dumb luck I changed our .eslintrc.yml to this
from this
So far so good…
This also worked for me, thanks!
Similarly as @aso1datov I’ve also updated following packages and it works for me.