繁体   English   中英

尝试在 Angular 应用程序中安装 ngrx 时出错

[英]Getting error while trying to install ngrx in Angular application

我正在尝试在我的 Angular 应用程序中安装 ngrx。 我已经执行了命令

ng 添加@ngrx/store@latest

但它会导致错误如下

npm 解析错误报告

2022-07-07T20:36:16.089Z

解决时: crudapp@0.0.0 发现: @angular/core@13.3.11 node_modules/@angular/core @angular/core@"~13.3.0" 从根项目

无法解决依赖关系:来自根项目的 @ngrx/store@14.0.1 的对等 @angular/core@"^14.0.0" node_modules/@ngrx/store @ngrx/store@"14.0.1"

修复上游依赖冲突,或使用 --force 或 --legacy-peer-deps 重试此命令以接受不正确(并且可能损坏)的依赖解析。

原始 JSON 解释对象:

{
  "code": "ERESOLVE",
  "current": {
    "name": "@angular/core",
    "version": "13.3.11",
    "whileInstalling": {
      "name": "crudapp",
      "version": "0.0.0",
      "path": "/home/Projects/Learning/Angular-ngrx-CRUD/angular-ngrx-crud"
    },
    "location": "node_modules/@angular/core",
    "dependents": [
      {
        "type": "prod",
        "name": "@angular/core",
        "spec": "~13.3.0",
        "from": {
          "location": "/home/Projects/Learning/Angular-ngrx-CRUD/angular-ngrx-crud"
        }
      }
    ]
  },
  "edge": {
    "type": "peer",
    "name": "@angular/core",
    "spec": "^14.0.0",
    "error": "INVALID",
    "from": {
      "name": "@ngrx/store",
      "version": "14.0.1",
      "whileInstalling": {
        "name": "crudapp",
        "version": "0.0.0",
        "path": "/home/Projects/Learning/Angular-ngrx-CRUD/angular-ngrx-crud"
      },
      "location": "node_modules/@ngrx/store",
      "dependents": [
        {
          "type": "prod",
          "name": "@ngrx/store",
          "spec": "14.0.1",
          "from": {
            "location": "/home/Projects/Learning/Angular-ngrx-CRUD/angular-ngrx-crud"
          }
        }
      ]
    }
  },
  "peerConflict": null,
  "strictPeerDeps": false,
  "force": false
}

任何人都可以对此有任何想法吗? 我已经尝试了一些角度版本更新和所有。 但它不起作用。

问题是 angular 和 ngrx/store 的版本不同,您的项目使用 angular 13,而 ngrx/store 试图找到 angular 14,因为您使用的是命令 @latest。 解决方案是您可以尝试使用 ng add @ngrx/store@13

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM