Search code examples
angularangularjsnpmangular-cliangular-ui-bootstrap

Errors when attempting to install ng-bootstrap, package installation failed


I am working on an Angular app, for which I need an accordion. I attempted to install the ng-bootstrap package by running the command 'ng add @ng-bootstrap/ng-bootstrap', but every time I try running it, the installation fails. I have went to almost every similar question posed on Stack Overflow & attempted to use their solution, to no avail & its starting to get a bit frustrating. If anyone has an idea of what's causing all this bs, please let me know as your help would be greatly appreciated. Full error message below:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR!   peer @angular/core@"15.2.0" from @angular/[email protected]
npm ERR!   node_modules/@angular/animations
npm ERR!     peerOptional @angular/animations@"15.2.0" from @angular/[email protected]
npm ERR!     node_modules/@angular/platform-browser
npm ERR!       peer @angular/platform-browser@"15.2.0" from @angular/[email protected]
npm ERR!       node_modules/@angular/forms
npm ERR!         @angular/forms@"^15.2.0" from the root project
npm ERR!       3 more (@angular/platform-browser-dynamic, @angular/router, the root project)
npm ERR!     @angular/animations@"^15.2.0" from the root project
npm ERR!   peer @angular/core@"15.2.0" from @angular/[email protected]
npm ERR!   node_modules/@angular/common
npm ERR!     peer @angular/common@"15.2.0" 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/common@"15.2.0" from @angular/[email protected]
npm ERR!     node_modules/@angular/platform-browser
npm ERR!       peer @angular/platform-browser@"15.2.0" from @angular/[email protected]
npm ERR!       node_modules/@angular/forms
npm ERR!         @angular/forms@"^15.2.0" from the root project
npm ERR!       3 more (@angular/platform-browser-dynamic, @angular/router, the root project)
npm ERR!     4 more (@angular/platform-browser-dynamic, @angular/router, ...)
npm ERR!   7 more (@angular/compiler, @angular/forms, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! @ng-bootstrap/ng-bootstrap@"14.1.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.7" 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.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 /Users/tazar/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tazar/.npm/_logs/2023-04-15T04_02_08_353Z-debug.log`

I attempted to run "ng update" & "npm i -g @angular/cli" to update the dependencies within my project, but nothing worked. I'm also not good with fixing dependencies at all, so Im a bit lost and am not sure what to do. 

Solution

  • I hope this commands can help you. First install:

    npm config set legacy-peer-deps true
    

    Then use below one:

    ng add @ng-bootstrap/ng-bootstrap