jsmin
jsmin

Reputation: 392

PrimeNG error ConfirmationService has not been processed correctly by ngcc, or is not compatible with Angular Ivy

I'm using PrimeNG 11 with angular 11 as per this configuration:

  "dependencies": {
"@angular/animations": "^11.2.2",
"@angular/cdk": "^11.2.1",
"@angular/common": "^11.2.2",
"@angular/compiler": "^11.2.2",
"@angular/core": "^11.2.2",
"@angular/forms": "^11.2.2",
"@angular/platform-browser": "^11.2.2",
"@angular/platform-browser-dynamic": "^11.2.2",
"@angular/router": "^11.2.2",
"@auth0/angular-jwt": "^5.0.2",
"bootstrap": "^5.0.0-beta2",
"primeicons": "^4.1.0",
"primeng": "^11.2.3",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"typescript-map": "^0.1.0",
"zone.js": "^0.10.3"  }

After importing the module & service to use the confirm dialog component we got an error

This likely means that the library (primeng/api) which declares ConfirmationService has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is a

vailable, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

The import lines

import {ConfirmDialogModule} from 'primeng/confirmdialog'; import {ConfirmationService} from 'primeng/api';

I tried

  1. Delete node-modules and run npm update
  2. Adding this line to scripts in package.json ["postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"]

None of these worked with me.

Can somebody please help with this ?

Upvotes: 2

Views: 3825

Answers (1)

jsmin
jsmin

Reputation: 392

I found that I was importing ConfirmationService instead of adding it to the providers. After adding it to providers it worked just fine. The error message was totally misleading.

Upvotes: 9

Related Questions