npm unable to resolve dependency tree when create a ionic app React

Issue

I have try to delete all npm package, uninstall ionic and many other things but I cannot pass this error.
I have even verify that the version of typescript and react-script exist (like in another post where the version doesn’t exist)

Full log:

λ ionic start myApp
? Framework: React
? Starter template: sidemenu
? .\myApp exists. Overwrite? Yes
√ Preparing directory .\myApp in 10.64ms
√ Downloading and extracting sidemenu starter in 830.02ms
> ionic integrations enable capacitor --quiet -- myApp io.ionic.starter
> npm.cmd i --save -E @capacitor/core
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: typescript@4.1.3
npm ERR! node_modules/typescript
npm ERR!   typescript@"4.1.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@4.0.1
npm ERR! node_modules/react-scripts
npm ERR!   react-scripts@"4.0.1" 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 C:\Users\<user>\AppData\Local\npm-cache\eresolve-report.txt for a full report.
> npm.cmd i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: typescript@4.1.3
npm ERR! node_modules/typescript
npm ERR!   typescript@"4.1.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@4.0.1
npm ERR! node_modules/react-scripts
npm ERR!   react-scripts@"4.0.1" 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 C:\Users\<user>\AppData\Local\npm-cache\eresolve-report.txt for a full report.

Solution

In fact, instead of trying to –force the command about 10 times, we need to use the –legacy-peer-deps. Maybe force isn’t the good choice everywhere.

npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps

Answered By – Tryliom

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published