安装@angular/localize后,npm update/npm install 返回依赖错误

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

我想为我的角度应用程序使用@angular/localize。我正在 Nx monorepo 中使用最近创建的 Nestjs 后端和 Angular 前端。

尝试使用

npm install @angular/localize
添加包时,出现以下错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @wordle-ase/[email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~17.1.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"17.2.3" from @angular/[email protected]
npm ERR! node_modules/@angular/localize
npm ERR!   @angular/localize@"^17.2.3" 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.

因为我想要一个干净的软件包安装,没有依赖性问题,所以我不想使用

--force
--legacy-peer-deps

当我看到 @angular/[email protected] 依赖于 @angular/[email protected] 并且我只安装了 17.1.3 版本时,我也尝试安装 localize 17.1.3 版本 (

npm install @angular/[email protected]
) 。该命令没有返回错误。

如果我随后使用命令

npm update
以及
npm install
,我会收到非常相似的错误消息:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @wordle-ase/[email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~17.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"17.2.3" from @angular/[email protected]
npm ERR! node_modules/@angular/localize
npm ERR!   @angular/localize@"^17.1.3" 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.

为什么我会收到此错误?它是可以修复的还是甚至是预期的行为? 如果 @angular/localize 存在问题,我可以不更新其他软件包吗?为什么即使第一次安装时没有依赖问题,我也不能重新安装所有软件包而不会出现错误?

如果它有用,这是我的完整 package.json 文件:

{
  "name": "@wordle-ase/source",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {},
  "private": true,
  "dependencies": {
    "@angular/animations": "~17.1.0",
    "@angular/cdk": "^17.2.1",
    "@angular/common": "~17.1.0",
    "@angular/compiler": "~17.1.0",
    "@angular/core": "~17.1.0",
    "@angular/forms": "~17.1.0",
    "@angular/localize": "^17.1.3",
    "@angular/material": "~17.2.1",
    "@angular/platform-browser": "~17.1.0",
    "@angular/platform-browser-dynamic": "~17.1.0",
    "@angular/router": "~17.1.0",
    "@nestjs/common": "^10.0.2",
    "@nestjs/core": "^10.0.2",
    "@nestjs/jwt": "^10.2.0",
    "@nestjs/mapped-types": "*",
    "@nestjs/mongoose": "^10.0.4",
    "@nestjs/platform-express": "^10.0.2",
    "@nestjs/swagger": "^7.3.0",
    "@nrwl/angular": "^18.0.5",
    "axios": "^1.6.0",
    "mongoose": "^8.2.1",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.2.2",
    "@angular-devkit/core": "~17.1.0",
    "@angular-devkit/schematics": "~17.1.0",
    "@angular-eslint/eslint-plugin": "~17.0.0",
    "@angular-eslint/eslint-plugin-template": "~17.0.0",
    "@angular-eslint/template-parser": "~17.0.0",
    "@angular/cli": "~17.1.0",
    "@angular/compiler-cli": "~17.1.0",
    "@angular/language-service": "~17.1.0",
    "@angular/material": "^17.2.1",
    "@nestjs/schematics": "^10.0.1",
    "@nestjs/testing": "^10.0.2",
    "@nx/eslint": "18.0.3",
    "@nx/eslint-plugin": "18.0.3",
    "@nx/jest": "18.0.5",
    "@nx/js": "18.0.5",
    "@nx/nest": "^18.0.3",
    "@nx/node": "18.0.3",
    "@nx/web": "18.0.3",
    "@nx/webpack": "18.0.3",
    "@nx/workspace": "18.0.3",
    "@schematics/angular": "~17.1.0",
    "@swc-node/register": "~1.8.0",
    "@swc/core": "~1.3.85",
    "@swc/helpers": "~0.5.2",
    "@types/jest": "^29.4.0",
    "@types/node": "~18.16.9",
    "@typescript-eslint/eslint-plugin": "^6.13.2",
    "@typescript-eslint/parser": "^6.13.2",
    "eslint": "~8.48.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-cypress": "^2.13.4",
    "jest": "^29.4.1",
    "jest-environment-jsdom": "^29.4.1",
    "jest-environment-node": "^29.4.1",
    "jest-preset-angular": "~13.1.4",
    "jsonc-eslint-parser": "^2.1.0",
    "nx": "18.0.3",
    "prettier": "^2.6.2",
    "ts-jest": "^29.1.0",
    "ts-node": "10.9.1",
    "typescript": "~5.3.2",
    "webpack-cli": "^5.1.4"
  }
}
angular npm nestjs nrwl-nx angular-localize
1个回答
0
投票

更改 package.json 中的接下来两个字段

"@angular/compiler": "~17.1.0",
"@angular/localize": "^17.1.3",

"@angular/compiler": "^17.1.0",
"@angular/localize": "^17.1.0",

然后运行

npm install

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