Home > OS >  Getting error while trying to install ngrx in Angular application
Getting error while trying to install ngrx in Angular application

Time:07-09

I am trying to install ngrx in my Angular application. I have executed the command

ng add @ngrx/store@latest

But it results in an error as follows

npm resolution error report

2022-07-07T20:36:16.089Z

While resolving: [email protected] Found: @angular/[email protected] node_modules/@angular/core @angular/core@"~13.3.0" from the root project

Could not resolve dependency: peer @angular/core@"^14.0.0" from @ngrx/[email protected] node_modules/@ngrx/store @ngrx/store@"14.0.1" from the root project

Fix the upstream dependency conflict, or retry this command with --force, or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.

Raw JSON explanation object:

{
  "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
}

Can anyone have any idea about the same? I have tried with some angular version updations and all. But it doesn't work.

CodePudding user response:

The problem is there is a different version of angular and ngrx/store, your project uses angular 13, and the ngrx/store trying to find angular 14 because you are using command @latest. The solution is you can try to use ng add @ngrx/store@13

  • Related