Angular NPM Install error even though install matches peer range

Discussão em 'Angular' iniciado por dcp3450, Janeiro 8, 2025.

  1. dcp3450

    dcp3450 Guest

    I currently manage all my application dependencies in a company managed npm package. We have multiple applications so when I need to update packages, this helps me one and done it for the most part. I don't do this for devDependencies yet but that's coming.

    managed package's package.json peerDependencies:

    "peerDependencies": {
    "@angular/animations": "^18.2.13",
    "@angular/common": "^18.2.13",
    "@angular/core": "^18.2.13",
    "@angular/forms": "^18.2.13",
    "@angular/cdk": "18.2.13",
    "@angular/compiler": "18.2.13",
    "@angular/material": "18.2.13",
    "@angular/material-moment-adapter": "18.2.13",
    "@angular/platform-browser": "^18.2.13",
    "@angular/platform-browser-dynamic": "^18.2.13",
    "@angular/router": "18.2.13",
    "@aws-amplify/ui-angular": "^4.0.10",
    "@material/theme": "^15.0.0-canary.2a9697dc5.0",
    "@types/deep-diff": "1.0.5",
    "@types/luxon": "^3.4.2",
    "aws-amplify": "~5.3.27",
    "aws-sdk": "^2.1692.0",
    "core-js": "^3.38.1",
    "corejs": "^1.0.0",
    "custom-event-polyfill": "^1.0.7",
    "echarts": "^5.6.0",
    "file-saver": "^2.0.1",
    "filepond": "^4.31.4",
    "filepond-plugin-file-validate-type": "^1.2.4",
    "lodash": "^4.17.21",
    "luxon": "^3.5.0",
    "moment": "^2.30.1",
    "ngx-echarts": "^18.0.0",
    "ngx-extended-pdf-viewer": "^21.4.6",
    "ngx-filepond": "^7.0.3",
    "ngx-pagination": "^6.0.3",
    "rxjs": "^7.8.1",
    "sanitize.css": "^13.0.0",
    "tslib": "^2.8.1",
    "zone.js": "~0.14.10"
    }


    application package.json (note the tgz file is just for testing things, it's AWS hosted when live):

    "dependencies": {
    "@my_appstore/company-shared": "file:my_appstore-company-shared-17.4.17.tgz"
    },
    "devDependencies": {
    "@angular-devkit/build-angular": "^18.2.12",
    "@angular-builders/custom-webpack": "^18.0.0",
    "@angular/cli": "18.2.12",
    "@angular/compiler-cli": "18.2.13",
    "@faker-js/faker": "^9.3.0",
    "@ngneat/spectator": "^16.0.0",
    "@types/jasmine": "~4.3.5",
    "@types/jasminewd2": "~2.0.3",
    "@types/jest": "^29.5.2",
    "@types/node": "^18.19.14",
    "@typescript-eslint/eslint-plugin": "^8.19.0",
    "@typescript-eslint/parser": "^8.19.0",
    "commit-and-tag-version": "^11.3.0",
    "eslint": "^8.57.1",
    "eslint-config-angular": "^0.5.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-angular": "^4.1.0",
    "eslint-plugin-html": "^8.1.2",
    "eslint-plugin-prettier": "^5.2.1",
    "jasmine-core": "~4.0.0",
    "jest": "^29.5.0",
    "jest-junit": "^16.0.0",
    "jest-preset-angular": "^14.4.2",
    "ng-mocks": "^14.11.0",
    "prettier": "3.3.3",
    "pretty-quick": "^4.0.0",
    "sass-lint": "^1.12.1",
    "tslint-jasmine-rules": "^1.6.1",
    "typescript": "^5.5.4"
    }


    The issue that I have is during an npm i I get this:

    npm ERR! Found: @angular/core@18.2.13
    npm ERR! node_modules/@angular/core
    npm ERR! peer @angular/core@">=15.0.0 <20.0.0" from jest-preset-angular@14.4.2
    npm ERR! node_modules/jest-preset-angular
    npm ERR! dev jest-preset-angular@"^14.4.2" from the root project
    npm ERR! peerOptional @angular/core@"18.2.13" from @angular/compiler@18.2.13
    npm ERR! node_modules/@angular/compiler
    npm ERR! peer @angular/compiler@"18.2.13" from @angular/compiler-cli@18.2.13
    npm ERR! node_modules/@angular/compiler-cli
    npm ERR! dev @angular/compiler-cli@"18.2.13" from the root project
    npm ERR! 1 more (jest-preset-angular)
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! peer @angular/core@"19.0.5" from @angular/common@19.0.5
    npm ERR! node_modules/@angular/common
    npm ERR! peer @angular/common@"19.0.5" from @angular/platform-browser-dynamic@19.0.5
    npm ERR! node_modules/@angular/platform-browser-dynamic
    npm ERR! peer @angular/platform-browser-dynamic@">=15.0.0 <20.0.0" from jest-preset-angular@14.4.2
    npm ERR! node_modules/jest-preset-angular
    npm ERR! dev jest-preset-angular@"^14.4.2" from the root project


    From what I can tell jest-preset-angular@"^14.4.2" requires @angular/platform-browser-dynamic between v15 and less that v20 so NPM grabs the latest, v19.05. Which in turn wants Angular versions 19.0.5.

    However, I'm upgrading to 18 so I'm focused on v18.2.13. Obviously there's a conflict between v18 being installed and v19 being expected. I feel like if I can prevent jest-preset-angular from pulling v19 or convince the system that v18 satisfies the 15 -> 20 requirement I can resolve this issue. Need it to be maintainable too since we have 5 applications and growing.

    Continue reading...

Compartilhe esta Página