如何解决与 Nx、Angular 和 Nest 的对等依赖冲突?

ant*_*nyb 5 javascript nest angular-material angular peer-dependencies

我有一个非常新鲜的 Nx 工作区。几个月前创建了一个 Angular 应用程序和一个 Nest 应用程序,没有任何问题。我在中断一段时间后回来启动一个新的 Angular 应用程序,现在我遇到了一堆我不知道如何解决的对等依赖冲突。我尝试添加该--legacy-peer-deps选项npm install并且这有效(4 个高漏洞),但是当我尝试运行时npx nx g @angular/material:ng-add我无法解决这些错误。

错误如下:

npm ERR! While resolving: @nestjs/core@7.6.18
npm ERR! Found: @nestjs/common@8.4.6
npm ERR! node_modules/@nestjs/common
npm ERR!   @nestjs/common@"^8.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^7.0.0" from @nestjs/core@7.6.18
npm ERR! node_modules/@nestjs/core
npm ERR!   @nestjs/core@"^7.5.5" from the root project
npm ERR!   peer @nestjs/core@"^7.0.0" from @nestjs/platform-express@7.6.18
npm ERR!   node_modules/@nestjs/platform-express
npm ERR!     @nestjs/platform-express@"^7.5.5" from the root project
npm ERR!     2 more (@nestjs/core, @nestjs/testing)
npm ERR!   1 more (@nestjs/testing)
npm ERR!
npm ERR! Conflicting peer dependency: @nestjs/common@7.6.18
npm ERR! node_modules/@nestjs/common
npm ERR!   peer @nestjs/common@"^7.0.0" from @nestjs/core@7.6.18
npm ERR!   node_modules/@nestjs/core
npm ERR!     @nestjs/core@"^7.5.5" from the root project
npm ERR!     peer @nestjs/core@"^7.0.0" from @nestjs/platform-express@7.6.18
npm ERR!     node_modules/@nestjs/platform-express
npm ERR!       @nestjs/platform-express@"^7.5.5" from the root project
npm ERR!       2 more (@nestjs/core, @nestjs/testing)
npm ERR!     1 more (@nestjs/testing)
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)

ant*_*nyb 2

我不太确定它最终是如何解决的,但我只是慢慢地将冲突的依赖项回拨到以前的版本,直到没有依赖项冲突。这导致了 8 个高漏洞,然后我运行npm audit fix --force并删除了所有漏洞。

只是为了确保,我更新了 Nx(根据他们的文档),现在我不再有问题、警告或错误。

如果有人知道为什么这解决了我的问题,我很想听听解释。