react-scripts 4.0.3 crashes during npm install if package.json includes eslint
See original GitHub issueDescribe the bug
If eslint is included in a create-react-app project, npm install crashes.
Steps to reproduce:
- Install node
14.14.0
and npm version7.7.1
npx create-react-app my-app --template typescript
- Add dependency
"eslint": "7.22.0"
topackage.json
- Remove
package-lock.json
- Remove
node_modules
npm cache clear --force
- Run
npm install
Result:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: @babel/core@7.12.3
npm ERR! node_modules/@babel/core
npm ERR! @babel/core@"7.12.3" from react-scripts@4.0.3
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"^4.0.3" from the root project
npm ERR! @babel/core@"^7.12.3" from @svgr/webpack@5.5.0
npm ERR! node_modules/@svgr/webpack
npm ERR! @svgr/webpack@"5.5.0" from react-scripts@4.0.3
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"^4.0.3" from the root project
npm ERR! 9 more (babel-jest, babel-loader, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @babel/core@"^7.13.0" from @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.13.12
npm ERR! node_modules/@babel/preset-env/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
npm ERR! @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@"^7.13.12" from @babel/preset-env@7.13.12
npm ERR! node_modules/@babel/preset-env
npm ERR! @babel/preset-env@"^7.12.1" from @svgr/webpack@5.5.0
npm ERR! node_modules/@svgr/webpack
npm ERR! @svgr/webpack@"5.5.0" from react-scripts@4.0.3
npm ERR! node_modules/react-scripts
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/jason/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jason/.npm/_logs/2021-03-24T20_18_14_307Z-debug.log
This is package.json:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.8.3",
"@types/jest": "^26.0.21",
"@types/node": "^12.20.6",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "^4.0.3",
"typescript": "^4.2.3",
"eslint": "^7.22.0",
"web-vitals": "^1.1.1"
},
"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"
]
}
}
It isn’t just eslint that triggers this crash. In my main project, I’ve changed all packages to the versions that appear in a fresh create-react-app install. I removed all eslint packages. Some other package in there is also causing this error.
UPDATE: I tried adding "@babel/core": "^7.13.0"
in the package.json file and that fixes the problem.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:5
Top Results From Across the Web
My create-react-app is failing to compile due to ESLint error
This issue has been fixed in the react-scipts:"4.0.3" but, the eslint ... We are going to add another script to our package.json file....
Read more >eslint/eslint - Gitter
Try running npm ls eslint in your project folder. This will tell you which other package (apart from the expected react-scripts) installed eslint....
Read more >Craco - npm
CRACO. Create React App Configuration Override, an easy and comprehensible configuration layer for create-react-app.
Read more >react-scripts - npm Package Health Analysis - Snyk
Ensure you're using the healthiest npm packages. Snyk scans all the packages in your projects for vulnerabilities and provides automated fix advice.
Read more >eslint couldn't find the config "react-app" to extend from ...
If ESLint is not able to find the react-app config, there are likely conflicting or duplicate ESLint config dependencies that were installed outside...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Installing the most recent node LTS version (v14.17.0) solved the problem for me.
Humm, if I see things correctly, the resolving dependency error occurs because create-react-app has the “@babel/core”: dependency fixed to “7.12.3” in its “packages.json” file. 3 days ago, @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining was merged to Babe master branch that requires “@babel/core” dependency to be “7.13.0” or greater. I don’t know create-react-app too well, but would perhaps relaxing the “@babel/core” dependency to “^7.12.3” be a proper way to fix this issue?