离子:ERESOLVE 无法解析:找到:rxjs@7.xx

Hak*_*aku 3 javascript rxjs ionic-framework angular rxjs7

在尝试使用电容器构建离子项目时,有人遇到这个问题吗?

我有一个 Ionic 项目,其中每个功能都有不同的包。我正在尝试使用将我的项目导出到 android studio 中ionic capacitor build android。我还尝试创建一个带有空白页面的新项目,效果很好。我的怀疑是本地软件包,但我不知道如何解决这个问题,因为我是角度和离子的新手。

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @ionic-native/core@5.36.0
npm ERR! Found: rxjs@7.4.0
npm ERR! node_modules/rxjs
npm ERR!   peer rxjs@"^6.5.3 || ^7.4.0" from @angular/common@15.0.2
npm ERR!   node_modules/@angular/common
npm ERR!     peer @angular/common@"15.0.2" from @angular/forms@15.0.2
npm ERR!     node_modules/@angular/forms
npm ERR!       peer @angular/forms@">=12.0.0" from @ionic/angular@6.3.9
npm ERR!       node_modules/@ionic/angular
npm ERR!         @ionic/angular@"^6.3.9" from the root project
npm ERR!       1 more (the root project)
npm ERR!     peer @angular/common@"15.0.2" from @angular/platform-browser@15.0.2
npm ERR!     node_modules/@angular/platform-browser
npm ERR!       peer @angular/platform-browser@"15.0.2" from @angular/forms@15.0.2
npm ERR!       node_modules/@angular/forms
npm ERR!         peer @angular/forms@">=12.0.0" from @ionic/angular@6.3.9
npm ERR!         node_modules/@ionic/angular
npm ERR!         1 more (the root project)
npm ERR!       3 more (@angular/platform-browser-dynamic, @angular/router, the root project)
npm ERR!     3 more (@angular/platform-browser-dynamic, @angular/router, the root project)
npm ERR!   peer rxjs@"^6.5.3 || ^7.4.0" from @angular/core@15.0.2
npm ERR!   node_modules/@angular/core
npm ERR!     peer @angular/core@"15.0.2" from @angular/common@15.0.2
npm ERR!     node_modules/@angular/common
npm ERR!       peer @angular/common@"15.0.2" from @angular/forms@15.0.2
npm ERR!       node_modules/@angular/forms
npm ERR!         peer @angular/forms@">=12.0.0" from @ionic/angular@6.3.9
npm ERR!         node_modules/@ionic/angular
npm ERR!         1 more (the root project)
npm ERR!       4 more (@angular/platform-browser, ...)
npm ERR!     peerOptional @angular/core@"15.0.2" from @angular/compiler@15.0.2
npm ERR!     node_modules/@angular/compiler
npm ERR!       peer @angular/compiler@"15.0.2" from @angular/compiler-cli@15.0.2
npm ERR!       node_modules/@angular/compiler-cli
npm ERR!         peer @angular/compiler-cli@"^15.0.0" from @angular-devkit/build-angular@15.0.2
npm ERR!         node_modules/@angular-devkit/build-angular
npm ERR!         2 more (@ngtools/webpack, the root project)
npm ERR!       2 more (@angular/platform-browser-dynamic, the root project)
npm ERR!     7 more (@angular/forms, @angular/platform-browser, ...)
npm ERR!   5 more (@angular/forms, @angular/router, @ionic/angular, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"^5.5.0 || ^6.5.0" from @ionic-native/core@5.36.0
npm ERR! node_modules/@ionic-native/core
npm ERR!   peer @ionic-native/core@"^5.1.0" from @ionic-native/network@5.36.0
npm ERR!   node_modules/@ionic-native/network
npm ERR!     @ionic-native/network@"^5.36.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: rxjs@6.6.7
npm ERR! node_modules/rxjs
npm ERR!   peer rxjs@"^5.5.0 || ^6.5.0" from @ionic-native/core@5.36.0
npm ERR!   node_modules/@ionic-native/core
npm ERR!     peer @ionic-native/core@"^5.1.0" from @ionic-native/network@5.36.0
npm ERR!     node_modules/@ionic-native/network
npm ERR!       @ionic-native/network@"^5.36.0" 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.
Run Code Online (Sandbox Code Playgroud)

小智 6

您存在依赖冲突,可能是因为@ionic-native包装器不再更新并且 Ionic 使用最新的 Angular 15。

尝试将所有@ionic-native软件包替换为@awesome-cordova-plugins对应的软件包。

实施例1:npm un @ionic-native/core && npm i @awesome-cordova-plugins/core

实施例2:npm un @ionic-native/social-sharing && npm i @awesome-cordova-plugins/social-sharing

等等...

如果您在执行此操作时遇到相同的错误,请在每个 npm i 命令后添加 --force 标志。