node.jsangularupgrade

After angular upgrade, new npm not installing without force command


I have upgraded my old angular project from version 10 to 19 steps by steps (https://angular.dev/update-guide). Now after upgrade everything is working fine. The only issue I am facing is that to install new npm I have to use "--force' command. Without "--force" command I am getting below error:

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: ng-recaptcha@13.2.1
npm error Found: @angular/core@19.2.5
npm error node_modules/@angular/core
npm error   peer @angular/core@"19.2.5" from @angular/animations@19.2.5
npm error   node_modules/@angular/animations
npm error     peerOptional @angular/animations@"19.2.5" from @angular/platform-browser@19.2.5
npm error     node_modules/@angular/platform-browser
npm error       peer @angular/platform-browser@"19.2.5" from @angular/forms@19.2.5
npm error       node_modules/@angular/forms
npm error         peer @angular/forms@"^19.0.0 || ^20.0.0" from @angular/material@19.2.8
npm error         node_modules/@angular/material
npm error         4 more (ngx-bootstrap, ngx-intl-tel-input, primeng, the root project)
npm error       6 more (@angular/material, ...)
npm error     peer @angular/animations@"^19.0.1" from ngx-bootstrap@19.0.2
npm error     node_modules/ngx-bootstrap
npm error       peer ngx-bootstrap@">= 12.0.0" from ngx-intl-tel-input@17.0.0
npm error       node_modules/ngx-intl-tel-input
npm error         ngx-intl-tel-input@"^17.0.0" from the root project
npm error       1 more (the root project)
npm error     3 more (ngx-spinner, primeng, the root project)
npm error   peer @angular/core@"^19.0.0 || ^20.0.0" from @angular/cdk@19.2.8
npm error   node_modules/@angular/cdk
npm error     peer @angular/cdk@"19.2.8" from @angular/material@19.2.8
npm error     node_modules/@angular/material
npm error       @angular/material@"^19.2.8" from the root project
npm error     peer @angular/cdk@">=13.0.0" from ngx-scrollbar@9.0.2
npm error     node_modules/ngx-scrollbar
npm error       ngx-scrollbar@"^9.0.0" from the root project
npm error     2 more (primeng, the root project)
npm error   21 more (@angular/common, @angular/forms, @angular/material, ...)
npm error
npm error Could not resolve dependency:
npm error peer @angular/core@"^17.0.0" from ng-recaptcha@13.2.1
npm error node_modules/ng-recaptcha
npm error   ng-recaptcha@"^13.2.1" from the root project
npm error
npm error Conflicting peer dependency: @angular/core@17.3.12
npm error node_modules/@angular/core
npm error   peer @angular/core@"^17.0.0" from ng-recaptcha@13.2.1
npm error   node_modules/ng-recaptcha
npm error     ng-recaptcha@"^13.2.1" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.

Please let me know what is wrong with upgrade. Should I assume my upgrade done properly and will not cause any issue in future.

Thanks


Solution

  • ng-recaptcha@13.2.1 is using angular 17.x.x. You need to overrides the dependencies for ng-recaptcha.like

    "overrides": {
        "ng-recaptcha": {
            "@angular/common": "^19.0.0",
            "@angular/core": "^19.0.0"
        }
    }
    

    Add those dependencies in overrides which you are getting at runtime.