簡體   English   中英

Angular 從 v12 遷移到 v14

[英]Angular migration from v12 to v14

我已將我的 Angular 版本從 v12 遷移到 v13,在此過程中,我嘗試刪除 node_modules 並再次嘗試安裝 node_modules 但我無法使用直接安裝 npm 來執行此操作,並且我收到以下錯誤:

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>

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
}

奇怪的是,我可以通過將 --force 或 --legacy-peer-deps 安裝到 npm 安裝后使用特殊命令來安裝 npm 。 誰能幫我解決這個問題。

謝謝。

如上所述,您可以使用npm info @ncstate/sat-popover@7.1.0 peerDependencies測試特定版本的@ncstate/sat-popover@7.1.0的對等依賴項。

結果:

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

根據錯誤,對於 Angular 13 項目,您至少需要版本npm info @ncstate/sat-popover@9.0.0

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

所以要么安裝更高版本npm install @ncstate/sat-popover@9.0.0要么將您的 Angular 版本降級到 11。

或者,使用npm i --legacy-peer-deps忽略對等依賴項(根據錯誤)。

或者,使用ng update升級到 Angular 14 然后npm install @ncstate/sat-popover@latest 版本 10.0.0 支持 Angular 14 對等體。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM