Suikei
Suikei

Reputation: 23

How to resolve ngx-bootstrap Dependency Error

I got the following error, What's the meaning of this error log and do you know how to fix it ? Thanks.

137 error code ERESOLVE
138 error ERESOLVE could not resolve
139 error
140 error While resolving: [email protected]
140 error Found: @angular/[email protected]
140 error node_modules/@angular/animations
140 error   peer @angular/animations@"^16.0.0 || ^17.0.0" from @angular/[email protected]
140 error   node_modules/@angular/material
140 error     @angular/material@"^16.2.14" from the root project
140 error   peerOptional @angular/animations@"16.2.12" from @angular/[email protected]
140 error   node_modules/@angular/platform-browser
140 error     peer @angular/platform-browser@"16.2.12" from @angular/[email protected]
140 error     node_modules/@angular/forms
140 error       peer @angular/forms@"^16.0.0 || ^17.0.0" from @angular/[email protected]
140 error       node_modules/@angular/material
140 error         @angular/material@"^16.2.14" from the root project
140 error       1 more (the root project)
140 error     peer @angular/platform-browser@"^16.0.0 || ^17.0.0" from @angular/[email protected]
140 error     node_modules/@angular/material
140 error       @angular/material@"^16.2.14" from the root project
140 error     3 more (@angular/platform-browser-dynamic, @angular/router, the root project)
140 error   1 more (the root project)
140 error
140 error Could not resolve dependency:
140 error peer @angular/animations@"^17.0.0" from [email protected]
140 error node_modules/ngx-bootstrap
140 error   ngx-bootstrap@"^12.0.0" from the root project
140 error
140 error Conflicting peer dependency: @angular/[email protected]
140 error node_modules/@angular/animations
140 error   peer @angular/animations@"^17.0.0" from [email protected]
140 error   node_modules/ngx-bootstrap
140 error     ngx-bootstrap@"^12.0.0" from the root project
140 error
140 error Fix the upstream dependency conflict, or retry
140 error this command with --force or --legacy-peer-deps
140 error to accept an incorrect (and potentially broken) dependency resolution.

Should i use --force or --legacy-peer-deps to fix it ? dependency conflict is occurs very often and somehow feel like the library versioning installed like a mess.

Upvotes: 0

Views: 253

Answers (3)

Alex Umanskiy
Alex Umanskiy

Reputation: 46

let me help you with logs. It says that it can't install [email protected] because it found that you already got installed @angular/[email protected], probably it's in your package.json.

Next it mentions all libs that got dependency on @angular/animations and required versions per each @angular/[email protected] needs @angular/animations@"^16.0.0 || ^17.0.0", @angular/[email protected] needs @angular/animations@"16.2.12" etc. Ideally you got to find that one sweet version that satisfy them all, but in that case you got major version conflict and you got to follow our compatibility table as mentioned above.

In the end it concludes that it can't install [email protected] because it needs @angular/[email protected] and it conflicts with your root dependency. Hope your experience with ngx-bootstrap will be pleasant.

Upvotes: 1

Haris Ali
Haris Ali

Reputation: 145

It's an issue with the version of Angular and ngx-bootstrap you are using. ngx-bootstrap v12 doesn't seem compatible with Angular 16. You can either upgrade Angular to v17 or downgrade ngx-bootstrap to v11.

Upvotes: 1

JSON Derulo
JSON Derulo

Reputation: 17708

See the ngx-bootstrap compatibility table. You are trying to use ngx-bootstrap v12 with Angular v16, but they are not compatible. You now have two options:

  1. Update Angular to v17
  2. Downgrade ngx-bootstrap to v11

The options --force and --legacy-peer-deps should not be used in this case, as you have actual peer dependency conflicts which might lead to problems in your app.

It seems like since v18, the ngx-bootstrap major version now aligns with the Angular major version, so the peer dependency handling should be easier in future.

Upvotes: 1

Related Questions