Sushant Agrawal
Sushant Agrawal

Reputation: 11

NPM - Conflicting peer dependency angular v15 with @ng-bootstrap/ng-bootstrap

Here is my root package.json

"dependencies": {
    "@angular/animations": "^15.2.0",
    "@angular/cdk": "^15.2.9",
    "@angular/common": "^15.2.0",
    "@angular/compiler": "^15.2.0",
    "@angular/core": "^15.2.0",
    "@angular/forms": "^15.2.0",
    "@angular/material": "^15.2.9",
    "@angular/platform-browser": "^15.2.0",
    "@angular/platform-browser-dynamic": "^15.2.0",
    "@angular/router": "^15.2.0",
    "@ng-select/ng-select": "^10.0.4",
    "@ng-bootstrap/ng-bootstrap": "^14.0.0",
    "@popperjs/core": "^2.11.6",
    "bootstrap": "^5.2.3",
    "jspdf": "^2.5.1",
    "jspdf-autotable": "^3.8.2",
    "pdfkit": "^0.14.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"
  }

Here is the peerDependencies of package.json of @ng-bootstrap/ng-bootstrap.

"peerDependencies": {
    "@angular/common": "^15.0.0",
    "@angular/core": "^15.0.0",
    "@angular/forms": "^15.0.0",
    "@angular/localize": "^15.0.0",
    "@popperjs/core": "^2.11.6",
    "rxjs": "^6.5.3 || ^7.4.0"
  }

Here is the error message.

Could not resolve dependency:
npm ERR! @ng-bootstrap/ng-bootstrap@"^14.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR!   peer @angular/core@"15.2.10" from @angular/[email protected]
npm ERR!   node_modules/@angular/forms
npm ERR!     @angular/forms@"^15.2.0" from the root project
npm ERR!     peer @angular/forms@"^15.0.0" from @ng-bootstrap/[email protected]
npm ERR!     node_modules/@ng-bootstrap/ng-bootstrap
npm ERR!       @ng-bootstrap/ng-bootstrap@"^14.0.0" from the root project

My understanding is ng-bootstrap 14.x.x requires @angular/* versions ^15.0.0. And I have @angular/* versions ^15.2.x. And which seems to be compatible. Can anyone help why is this an issue ?

Upvotes: 1

Views: 91

Answers (1)

Naren Murali
Naren Murali

Reputation: 57986

For angular 15.2.0 Try installing 14.2.0 version of @ng-bootstrap

"@ng-bootstrap/ng-bootstrap": "^14.2.0",

So the command will be:

npm i @ng-bootstrap/ng-bootstrap@^14.2.0

Full Package JSON:

{
  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^15.2.0",
    "@angular/common": "^15.2.0",
    "@angular/compiler": "^15.2.0",
    "@angular/core": "^15.2.0",
    "@angular/forms": "^15.2.0",
    "@angular/platform-browser": "^15.2.0",
    "@angular/platform-browser-dynamic": "^15.2.0",
    "@angular/router": "^15.2.0",
    "@ng-bootstrap/ng-bootstrap": "^14.2.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0",
    "@ng-select/ng-select": "^10.0.4",
    "@popperjs/core": "^2.11.6",
    "bootstrap": "^5.2.3",
    "jspdf": "^2.5.1",
    "jspdf-autotable": "^3.8.2",
    "pdfkit": "^0.14.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.2.0",
    "@angular/cli": "~15.2.0",
    "@angular/compiler-cli": "^15.2.0",
    "@types/jasmine": "~4.3.0",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~4.9.4"
  }
}

Stackblitz Demo

Upvotes: 0

Related Questions