无法使用 Angular 13.3 安装 ngx-graph

Cannot install ngx-graph with Angular 13.3

我有一个 Angular v13.3 项目,我试图在其中安装 ngx-graph 的 v8.0.0。当我 运行 命令

npm install @swimlane/ngx-graph --save

我得到以下输出。

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: demo-ui@0.0.0
npm ERR! Found: rxjs@7.5.5
npm ERR! node_modules/rxjs
npm ERR!   rxjs@"~7.5.0" from the root project
npm ERR!   peer rxjs@"^6.5.3 || ^7.4.0" from @angular/core@13.3.1
npm ERR!   node_modules/@angular/core
npm ERR!     @angular/core@"~13.3.0" from the root project
npm ERR!     peer @angular/core@"10.x || 11.x || 12.x || 13.x" from @swimlane/ngx-graph@8.0.0
npm ERR!     node_modules/@swimlane/ngx-graph
npm ERR!       @swimlane/ngx-graph@"*" from the root project
npm ERR!     3 more (@angular/animations, @angular/cdk, @angular/common)
npm ERR!   2 more (@angular/cdk, @angular/common)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"6.x" from @swimlane/ngx-graph@8.0.0
npm ERR! node_modules/@swimlane/ngx-graph
npm ERR!   @swimlane/ngx-graph@"*" 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了,所以我不太清楚这是什么意思。 Angular 和 ngx-graph 要求的 rxjs 版本似乎有冲突。

npm install @swimlane/ngx-graph --save --legacy-peer-deps

几个版本之前,npm 自动为 peer deps 启动。使用上面的命令解决这个问题。