npm 在创建离子应用 React 时无法解析依赖树

时间:2021-02-03 15:42:56

标签: reactjs ionic-framework npm

我尝试删除所有 npm 包,卸载 ionic 和许多其他东西,但我无法通过此错误。 我什至验证了 typescript 和 react-script 的版本存在(就像在另一个版本不存在的帖子中一样)

完整日志:

λ 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.

1 个答案:

答案 0 :(得分:0)

事实上,我们需要使用 --legacy-peer-deps,而不是尝试 --force 命令大约 10 次。也许武力在任何地方都不是好选择。

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