ivyangular10

Error when activate Ivy compiler on Angular 10 error NG6003-could not resolve to a NgModule


We recently migrated our app to Angular 10 and PrimeNG 9, and now we are preparing to migrate these frameworks to the latest version.

We trying to prepare our app to migration and want to use Ivy Compiler as Angular recommends.

But when activate Ivy compiler and aot to true it shows the following error when do ng build:

ERROR in node_modules/@maestro-ng/primeng/maestro-primeng.module.d.ts:1:22 - error NG6003: Appears in the NgModule.exports of AppSharedModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.

This likely means that the library (@maestro-ng/primeng) which declares MaestroPrimengModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

This is the complete package.json:

{
  "name": "codex-frontend",
  "version": "1.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "dev": "ng serve -c dev --watch=false",
    "postinstall": "ngcc",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^10.2.5",
    "@angular/cdk": "^10.2.7",
    "@angular/common": "^10.2.5",
    "@angular/compiler": "^10.2.5",
    "@angular/core": "^10.2.5",
    "@angular/forms": "^10.2.5",
    "@angular/platform-browser": "^10.2.5",
    "@angular/platform-browser-dynamic": "^10.2.5",
    "@angular/router": "^10.2.5",
    "@fortawesome/fontawesome-free": "5.15.4",
    "@fullcalendar/core": "5.9.0",
    "@maestro-ng/core": "https://nexus.myorg.com.br/repository/npm-all/@maestro-ng/core/-/core-1.10.0.tgz",
    "@maestro-ng/primeng": "https://nexus.myorg.com.br/repository/npm-all/@maestro-ng/primeng/-/primeng-1.10.0.tgz",
    "@types/pdfjs-dist": "2.7.5",
    "bootstrap": "5.1.1",
    "chart.js": "3.5.1",
    "core-js": "3.18.0",
    "g": "2.0.1",
    "jquery": "3.6.0",
    "js-base64": "3.7.2",
    "moment": "2.29.1",
    "ng2-currency-mask": "9.0.2",
    "ng2-pdfjs-viewer": "6.0.2",
    "ngx-moment": "5.0.0",
    "pdfjs-dist": "2.9.359",
    "@popperjs/core": "2.10.1",
    "primeflex": "2.0.0",
    "primeicons": "4.0.0",
    "primeng": "9.1.3",
    "quill": "1.3.7",
    "rxjs": "6.6.2",
    "simple-pdf-viewer": "2.0.3",
    "tslib": "2.3.1",
    "zone.js": "^0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1000.8",
    "@angular/cli": "^10.2.3",
    "@angular/compiler-cli": "10.2.5",
    "@angular/language-service": "10.2.5",
    "@fortawesome/fontawesome-free": "5.8.2",
    "@types/jasmine": "3.9.1",
    "@types/jasminewd2": "2.0.10",
    "@types/node": "16.9.6",
    "codelyzer": "6.0.2",
    "jasmine-core": "3.9.0",
    "jasmine-spec-reporter": "7.0.0",
    "karma": "6.3.4",
    "karma-chrome-launcher": "3.1.0",
    "karma-cli": "2.0.0",
    "karma-coverage-istanbul-reporter": "3.0.3",
    "karma-jasmine": "4.0.1",
    "karma-jasmine-html-reporter": "1.7.0",
    "protractor": "7.0.0",
    "ts-node": "10.2.1",
    "tslint": "^5.20.1",
    "tslint-eslint-rules": "^5.4.0",
    "typescript": "3.9.7"
  }
}

Even when use `"postinstall": "ngcc" it does not work.

Is it possible to use Ivy With Angular 10 and PrimeNG 9 our we need to first migrate PrimeNG to 10?

enter image description here


Solution

  • The error is caused by an internal library that is not builded using Ivy.

    If you encounter this error because of an internal library of your company, make sure this library is builded using Ivy. As you may know already , ViewEngine is deprecated and will be removed soon.