Npm 安装因依赖项不匹配而失败。当我运行命令 npm install 时附加错误

问题描述 投票:0回答:2

解析时:@angular-eslint/[email protected] 发现:@angular/[email protected] 节点模块/@angular/cli 来自@angular-extensions/[email protected] 的同行@angular/cli@"^10.0.0" node_modules/@angular-extensions/模型 来自根项目的@angular-extensions/model@"^10.0.1" 来自根项目的 dev @angular/cli@"~10.0.8"

无法解决依赖关系: 同行@angular/cli@">= 12.0.0 < 13.0.0" from @angular-eslint/[email protected] node_modules/@angular-eslint/builder dev @angular-eslint/builder@"^12.0.0" from the root project

冲突的对等依赖:@angular/[email protected] 节点模块/@angular/cli 同行@angular/cli@">= 12.0.0 < 13.0.0" from @angular-eslint/[email protected] node_modules/@angular-eslint/builder dev @angular-eslint/builder@"^12.0.0" from the root project

原始JSON解释对象:

{
  "code": "ERESOLVE",
  "edge": {
    "type": "peer",
    "name": "@angular/cli",
    "spec": ">= 12.0.0 < 13.0.0",
    "error": "INVALID",
    "from": {
      "name": "@angular-eslint/builder",
      "version": "12.0.0",
      "location": "node_modules/@angular-eslint/builder",
      "isWorkspace": false,
      "dependents": [
        {
          "type": "dev",
          "name": "@angular-eslint/builder",
          "spec": "^12.0.0",
          "from": {
            "location": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients"
          }
        }
      ]
    }
  },
  "dep": {
    "name": "@angular/cli",
    "version": "12.2.18",
    "whileInstalling": {
      "name": "@angular-eslint/builder",
      "version": "12.0.0",
      "path": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients\\node_modules\\@angular-eslint\\builder"
    },
    "location": "node_modules/@angular/cli",
    "isWorkspace": false,
    "dependents": [
      {
        "type": "peer",
        "name": "@angular/cli",
        "spec": ">= 12.0.0 < 13.0.0",
        "error": "INVALID",
        "from": {
          "name": "@angular-eslint/builder",
          "version": "12.0.0",
          "location": "node_modules/@angular-eslint/builder",
          "isWorkspace": false,
          "dependents": [
            {
              "type": "dev",
              "name": "@angular-eslint/builder",
              "spec": "^12.0.0",
              "from": {
                "location": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients"
              }
            }
          ]
        }
      }
    ]
  },
  "current": {
    "name": "@angular/cli",
    "version": "10.0.8",
    "location": "node_modules/@angular/cli",
    "isWorkspace": false,
    "dependents": [
      {
        "type": "peer",
        "name": "@angular/cli",
        "spec": "^10.0.0",
        "from": {
          "name": "@angular-extensions/model",
          "version": "10.0.1",
          "location": "node_modules/@angular-extensions/model",
          "isWorkspace": false,
          "dependents": [
            {
              "type": "prod",
              "name": "@angular-extensions/model",
              "spec": "^10.0.1",
              "from": {
                "location": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients"
              }
            }
          ]
        }
      },
      {
        "type": "dev",
        "name": "@angular/cli",
        "spec": "~10.0.8",
        "from": {
          "location": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients"
        }
      }
    ]
  },
  "peerConflict": {
    "current": {
      "name": "@angular/cli",
      "version": "10.0.8",
      "location": "node_modules/@angular/cli",
      "isWorkspace": false,
      "dependents": [
        {
          "type": "peer",
          "name": "@angular/cli",
          "spec": "^10.0.0",
          "from": {
            "name": "@angular-extensions/model",
            "version": "10.0.1",
            "location": "node_modules/@angular-extensions/model",
            "isWorkspace": false,
            "dependents": [
              {
                "type": "prod",
                "name": "@angular-extensions/model",
                "spec": "^10.0.1",
                "from": {
                  "location": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients"
                }
              }
            ]
          }
        },
        {
          "type": "dev",
          "name": "@angular/cli",
          "spec": "~10.0.8",
          "from": {
            "location": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients"
          }
        }
      ]
    },
    "peer": {
      "name": "@angular/cli",
      "version": "12.2.18",
      "whileInstalling": {
        "name": "@angular-eslint/builder",
        "version": "12.0.0",
        "path": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients\\node_modules\\@angular-eslint\\builder"
      },
      "location": "node_modules/@angular/cli",
      "isWorkspace": false,
      "dependents": [
        {
          "type": "peer",
          "name": "@angular/cli",
          "spec": ">= 12.0.0 < 13.0.0",
          "error": "INVALID",
          "from": {
            "name": "@angular-eslint/builder",
            "version": "12.0.0",
            "location": "node_modules/@angular-eslint/builder",
            "isWorkspace": false,
            "dependents": [
              {
                "type": "dev",
                "name": "@angular-eslint/builder",
                "spec": "^12.0.0",
                "from": {
                  "location": "D:\\people-care-service\\azure-repos\\app-focus-360\\master-branch-clients\\Clients"
                }
              }
            ]
          }
        }
      ]
    }
  },
  "strictPeerDeps": false,
  "force": false,
  "isMine": true
}

我不想使用 --force 或 --legacy-peer-deps 命令,因为它给出了一个 不正确(并且可能损坏)依赖项解析。

这也是我的产品环境

npm dependency-injection angular-cli npm-install package.json
2个回答
0
投票

你试过 yarn 吗? 据我所知,npm 对循环依赖更敏感,这可能是你的问题。 也许使用 yarn 可以更快地解决这个问题。 你能提供 package.json 的例子进行测试吗


0
投票

我曾经遇到过这个错误,因为我的依赖项与我所做的 npm ls 不匹配,它在树结构(依赖项树)中列出了所有已安装的包及其依赖项(以及它们的版本)。在那里你可以看到需要哪个版本的依赖项 X,你也可以找到最好的依赖项或者尝试同时安装各种依赖项看看它是否有效。

© www.soinside.com 2019 - 2024. All rights reserved.