在Ionic 7项目中添加iOS,如何传递NPM --force参数

slmsl1lt  于 11个月前  发布在  Ionic
关注(0)|答案(1)|浏览(188)

我想运行“ionic capacitor add ios”并指定NPM --force参数。当我执行此命令时,“ionic capacitor add ios”做的第一件事是执行“npm.cmd i -E @capacitor/email protected(https://stackoverflow.com/cdn-cgi/l/email-protection)“。由于版本依赖性,NPM退出并停止。我可以运行“npm.cmd i -E @capacitor/email protected(https://stackoverflow.com/cdn-cgi/l/email-protection)--force”它完成了。我的问题是我如何让Ionic把力传递给NPM?
背景我最近从离子4更新到7.我们也从 cordova 切换到电容4,和Angular 15.我只是创建了一个新的项目,并拉在一个组件的时间旧代码.我更新插件,因为我去.这比你想象的更容易.
以前我的项目使用rxjs 6.5.0版本,但Ionic 7需要7.5.0或更高版本。当我运行“npm install”时,我有几个插件仍然需要email protected(https://stackoverflow.com/cdn-cgi/l/email-protection),因此我收到很多警告,安装失败。
然而,我使用了“npm install --force”并安装了所有内容。到目前为止,一切都按预期工作。我能够使用“ionic capacitor add android”添加Android支持而没有问题。有警告,但我已经测试了应用程序,一切似乎都很好。所有警告都与版本依赖有关。
现在是时候添加iOS支持了。当我运行“ionic capacitor add ios”时,我得到以下错误,iOS从未添加:
npm.cmd i -E @capacitor/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!code ERESOLVE npm ERR!ERESOLVE could not resolve npm ERR!npm ERR!While resolving:@ionic-native/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!Found:email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/rxjs npm ERR!peer rxjs@"^6.5.3|| ^7.4.0”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/common npm ERR!peer @angular/common@“15.2.9”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/forms npm ERR!peer @angular/forms@">=14.0.0”from @ionic/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@ionic/angular npm ERR!@ionic/angular@"^7.0.6”from the root project npm ERR!(根项目)npm ERR!peer @angular/common@“15.2.9”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/platform-browser npm ERR!peer @angular/platform-browser@“15.2.9”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/forms npm ERR!peer @angular/forms@">=14.0.0”from @ionic/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@ionic/angular npm ERR!1更多(the root project)npm ERR!3更多(@angular/platform-browser-dynamic,@angular/router,根项目)npm ERR!(@angular/platform-browser-dynamic,@angular/router,.)npm ERR!peer rxjs@"^6.5.3|| ^7.4.0”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/core npm ERR!peer @angular/core@“15.2.9”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/common npm ERR!peer @angular/common@“15.2.9”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/forms npm ERR!peer @angular/forms@">=14.0.0”from @ionic/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@ionic/angular npm ERR!1 more(the root project)npm ERR!5 more(@angular/platform-browser,.)npm ERR!peerOptional @angular/core@“15.2.9”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/compiler npm ERR!peer @angular/compiler@“15.2.9”from @angular/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular/compiler-build-angular npm ERR!peer @angular/compiler-build-angular @"^15.0.0”from @angular-devkit/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@angular-devkit/build-angular npm ERR!(@ngtools/webpack,根项目)npm ERR!2 more(@angular/platform-browser-dynamic,根项目)npm ERR!6更多(@angular/forms,@angular/platform-browser,.)npm错误!7更多(@angular/forms,@angular/router,.)npm错误!npm错误!无法解析依赖关系:npm错误!peer rxjs@"^5.5.0|| ^6.5.0”from @ionic-native/email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@ionic-native/calendar npm ERR!@ionic-native/calendar@"^5.36.0”from root project npm ERR!npm ERR!正在删除对等依赖项:email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/rxjs npm ERR!peer rxjs@"^5.5.0||“^6.5.0”from @ionic-native/email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) npm ERR!node_modules/@ionic-native/calendar npm ERR!@ionic-native/calendar@"^5.36.0”from root project npm ERR!npm ERR!修复上游依赖冲突,或使用--force或--legacy-peer-deps npm ERR!重试npm ERR!此命令以接受不正确(可能已损坏)的依赖解析。
有什么想法吗?谢谢。

qnakjoqk

qnakjoqk1#

我认为你不能将任何NPM参数传递给Ionic,但你可以使用一个项目级的.npmrc文件,包括force=true或任何其他NPM选项。
这将使NPM在您的项目文件夹下直接或间接由Ionic Cli执行时自动使用这些选项。
参见:https://docs.npmjs.com/cli/v10/configuring-npm/npmrc

相关问题