I am trying to install a react app but am unable and it always gives the below error and the whole node_modules folder vanishes.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"5.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-scripts@"^4.0.0" from @craco/craco@6.4.5
npm ERR! node_modules/@craco/craco
npm ERR! @craco/craco@"^6.4.3" from the root project
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/xoxo/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xoxo/.npm/_logs/2023-01-24T15_48_03_164Z-debug-0.log
And it is not also letting me install react-app-rewired
I tried with --force and --legacy-peer-deps but no luck, I am stuck at this since 3 hours, not able to reslove it from anywhere. Also tried methods told for clearing cache and installing again, but no luck their either.
Also for some private packages had used npm auth
with $NPM_TOKEN
but still gave the below error:
npm auth
npm ERR! code EUSAGE
npm ERR!
npm ERR! Manage package owners
npm ERR!
npm ERR! Usage:
npm ERR! npm owner add <user> <package-spec>
npm ERR! npm owner rm <user> <package-spec>
npm ERR! npm owner ls <package-spec>
npm ERR!
npm ERR! Options:
npm ERR! [--registry <registry>] [--otp <otp>]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces]
npm ERR!
npm ERR! alias: author
npm ERR!
npm ERR! Run "npm help owner" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xoxo/.npm/_logs/2023-01-26T07_54_36_914Z-debug-0.log
Solved the above with:
npm i
still failed hence used npm i --legacy-peer-deps
after npm cache clean --force
Voila! all dependencies got installed
The mistake I was first doing was trying npm auth, which is not required as npm
fetches it from the .envrc
and the .npmrc
file
Hence, try using these steps if you find any difficulty similar to this