简体   繁体   中英

Angular migration from v12 to v14

I have migrated my Angular version from v12 to v13, in this process i tried deleting the node_modules and again tried installing node_modules but i am not able to do this using straight npm install and I am getting these below errors:

D:\test\Fxt\Web\src\main\ui\material>npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: material@3.0.0
npm ERR! Found: @angular/cdk@13.3.9
npm ERR! node_modules/@angular/cdk
npm ERR!   @angular/cdk@"13.3.9" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/cdk@"^11.0.0" from @ncstate/sat-popover@7.1.0
npm ERR! node_modules/@ncstate/sat-popover
npm ERR!   @ncstate/sat-popover@"^7.1.0" 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\Machine\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\Machine\AppData\Local\npm-cache\_logs\2022-07-27T07_23_05_623Z-debug-0.log

D:\test\Fxt\Web\src\main\ui\material>

The full error report as follows of C:\Users\Machine\AppData\Local\npm-cache\eresolve-report.txt :

# npm resolution error report

2022-07-27T07:23:24.600Z

While resolving: material@3.0.0
Found: @angular/cdk@13.3.9
node_modules/@angular/cdk
  @angular/cdk@"13.3.9" from the root project

Could not resolve dependency:
peer @angular/cdk@"^11.0.0" from @ncstate/sat-popover@7.1.0
node_modules/@ncstate/sat-popover
  @ncstate/sat-popover@"^7.1.0" 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/cdk",
    "version": "13.3.9",
    "whileInstalling": {
      "name": "material",
      "version": "3.0.0",
      "path": "D:\\test\\Fxt\\Web\\src\\main\\ui\\material"
    },
    "location": "node_modules/@angular/cdk",
    "isWorkspace": false,
    "dependents": [
      {
        "type": "prod",
        "name": "@angular/cdk",
        "spec": "13.3.9",
        "from": {
          "location": "D:\\test\\Fxt\\Web\\src\\main\\ui\\material"
        }
      }
    ]
  },
  "currentEdge": {
    "type": "prod",
    "name": "@angular/cdk",
    "spec": "13.3.9",
    "from": {
      "location": "D:\\test\\Fxt\\Web\\src\\main\\ui\\material"
    }
  },
  "edge": {
    "type": "peer",
    "name": "@angular/cdk",
    "spec": "^11.0.0",
    "error": "INVALID",
    "from": {
      "name": "@ncstate/sat-popover",
      "version": "7.1.0",
      "whileInstalling": {
        "name": "material",
        "version": "3.0.0",
        "path": "D:\\test\\Fxt\\Web\\src\\main\\ui\\material"
      },
      "location": "node_modules/@ncstate/sat-popover",
      "isWorkspace": false,
      "dependents": [
        {
          "type": "prod",
          "name": "@ncstate/sat-popover",
          "spec": "^7.1.0",
          "from": {
            "location": "D:\\test\\Fxt\\Web\\src\\main\\ui\\material"
          }
        }
      ]
    }
  },
  "strictPeerDeps": false,
  "force": false
}

Strangely I am able to do npm install with special command by post-fixing --force or --legacy-peer-deps to npm install which is working. Can anyone help me out on this.

Thanks.

As stated above you can test peer dependencies for your specific version of @ncstate/sat-popover@7.1.0 using npm info @ncstate/sat-popover@7.1.0 peerDependencies .

Result:

{
  '@angular/common': '^11.0.0',
  '@angular/core': '^11.0.0',
  '@angular/cdk': '^11.0.0'
}

As per the error, for an Angular 13 project you will need at least version npm info @ncstate/sat-popover@9.0.0 .

{
  '@angular/common': '^13.3.6',
  '@angular/core': '^13.3.6',
  '@angular/cdk': '^13.3.6'
}

So either install later version npm install @ncstate/sat-popover@9.0.0 or downgrade your version of Angular to 11.

Alternatively, ignore the peer dependency (as per the error) with npm i --legacy-peer-deps .

Alternatively, upgrade to Angular 14 using ng update and then npm install @ncstate/sat-popover@latest . Version 10.0.0 supports Angular 14 peer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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