添加 Spartacus - 包具有未满足的对等依赖性

Adding Spartacus - Package has unmet peer dependencies

我刚刚使用最新的 angular CLI 13.3.6(节点 16.15.0,纱线 1.22.15)创建了一个全新的项目。我正在尝试按照此处所述添加斯巴达克斯:https://sap.github.io/spartacus-docs/building-the-spartacus-storefront-from-libraries-4-x/ 但是当我 运行

ng add @spartacus/schematics@latest

我收到以下错误:

‼ Package has unmet peer dependencies. Adding the package may not succeed. No terminal detected. '--skip-confirmation' can be used to bypass installation confirmation. Ensure package name is correct prior to '--skip-confirmation' option usage. Command aborted.

我也按照@AhmedSHA256 的建议尝试了 --force - 没用。这就是我得到的:

ng add @spartacus/schematics@latest --skip-confirmation --force

  • Determining package manager... i Using package manager: npm
  • Loading package information from registry... ‼ Package has unmet peer dependencies. Adding the package may not succeed.
  • Installing package...
    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE unable to resolve dependency tree
    npm ERR!
    npm ERR! While resolving: spartacus@0.0.0
    npm ERR! Found: @angular/compiler@13.3.9
    npm ERR! node_modules/@angular/compiler
    npm ERR! @angular/compiler@"~13.3.0" from the root project
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! peer @angular/compiler@"^12.0.5" from @spartacus/schematics@4.3.3
    npm ERR! node_modules/@spartacus/schematics
    npm ERR! dev @spartacus/schematics@"4.3.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 C:\Users\kpw\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\kpw\AppData\Local\npm-cache_logs22-05-20T09_54_05_770Z-debug-0.log × Package install failed, see above.

如何添加斯巴达克斯?

斯巴达克斯 v4 仅支持 Angular v12

在撰写本文时,最新版本的 Spartacus (v4) 仅支持 Angular 12。您已安装 Angular 13,这可能就是您收到有关不兼容对等依赖项警告的原因.有关更多信息,请参阅 requirements docs of Spartacus v4.

请创建一个新的 Angular 12 应用程序,然后安装 Spartacus v4。

注意:Spartacus (v5) 的未来主要版本计划支持 Angular 的新主要版本。

如何在特定版本中安装 Spartacus(和 Angular)