Unable to install React application dependencies because the node_modules folder is missing and an error is thrown
P粉616111038
P粉616111038 2023-09-04 17:12:27
0
1
572
<p>I am trying to install a React app but it cannot be installed, it always gives the following error and the entire node_modules folder disappears. </p> <pre class="brush:php;toolbar:false;">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</pre> <p>And it won’t let me install <code>react-app-rewired</code></p> <p> I tried using --force and --legacy-peer-deps but no luck, I've been stuck here for 3 hours and can't solve it from anywhere. Also tried clearing cache and reinstalling, but no luck either. </p> <p>For some private packages, I used <code>npm auth</code> and <code>$NPM_TOKEN</code>, but I still get the following error: </p> <pre class="brush:php;toolbar:false;">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</pre></p>
P粉616111038
P粉616111038

reply all(1)
P粉536532781

Solved the above problem using the following methods:

  1. Delete and re-clone the project
  2. Created npmjs token for custom private package and updated it in .envrc file.
  3. So after npm i failed, npm i --legacy-peer-deps was used, before running npm cache clean --force

Wow! All dependencies are installed

The mistake I made initially was trying to use npm auth, but that wasn't actually needed because npm would pull the code from the .envrc and .npmrc files Get it

So if you face similar difficulties, please try these steps

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!