Primeng: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class

Created on 27 Aug 2019  路  26Comments  路  Source: primefaces/primeng

When I enabled the ivy renderer in my existing angular app , primeng components stopped working with the following errors.
Screenshot from 2019-08-27 11-52-45
Is there anyone here who experienced the same problem when working with ivy renderer?
any help is greatly appreciated.

Most helpful comment

Setting "aot": false inside angular.json file worked for me.

All 26 comments

Please search for related issues - https://github.com/primefaces/primeng/issues/7885

Related issue is closed, this issue remains.

Having this issue on 9.0.0-rc.2 for the SharedModule

Issue remains on official Angular 9.0.0.

It is happening on an old library.

The same!
image

I have the same issue with Angular/cli 9.0.1

Setting "aot": false inside angular.json file worked for me.

Guys, i have some solution but im not sure how currect it is.

1. "buildOptimizer": false,
2. "enableIvy": true
3. "aot": false,

Before do this refactoring, application size is: 18 440KB;
After: 17 887KB

The problem is Directives are declared in imports (module.ts)
Right way==>directives will import in declarations (module.ts)

same problem was happened for me. now my issue is solved

The problem is Directives are declared in imports (module.ts)
Right way==>directives will import in declarations (module.ts)

same problem was happened for me. now my issue is solved

Can you elaborate what you did exactly?

I have just upgraded my project to the newest version of Angular. I get this error too. I search a workaround for this.

Same issue on latest. "aot": false in Angular.json worked for me

I was wrong. I've upgraded Angular, but forgot to update Primeng to the newest rc's version. npm-check-updates doesn't show available unstable packages without --newest flag.
Now everything works fine.

Setting "aot": false inside angular.json file worked for me.

Yap it was fabulous

Hi guys, I figured out what going wrong, I had a Angular 8 project (containing a library project) that I have upgraded to Angular 9 (with a lib also: ng generate library core, I created at first a new angular 9 project to compare the differences with my project made with ng 8, i figure out that there is some things missing, here is the steps I followed:

  • Delete node_modules
  • Delete dist folder
  • In the Angular 9 project lib there is a new file called: tsconfig.lib.prod.json
{
  "extends": "./tsconfig.lib.json",
  "angularCompilerOptions": {
    "enableIvy": false
  }
}
  • In your angular.json add the following:
{
  ...
  "projects": {
     ...
     "configurations": {
            "production": {
              "tsConfig": "projects/core/tsconfig.lib.prod.json"
             }
      }
  ...
  }
}
  • run ng build --prod, and everything will work :D

PS: in this case the library is called "core"

I have the same issue with Angular/cli 9.0.1

For me, I ended up having to upgrade that particular old library to the latest version (which I should have done ages ago, but hey... lazy and stuff...) That library dated back to Angular 2 days.

With the old Angular 2.x library, it only builds with Angular 9 if you sent aot=false and do a non-production build. Production builds or aot=true will trigger this error. Nevertheless, the build will not run as webpack errors will start showing up.

Therefore, my suggestion is to upgrade whatever old dependencies to newer versions. This sucks because it means that libraries written for older Angular versions now break with Angular 9. They have all been working flawlessly up till version 8.

Is there any way to make it work with aot=true and Angular 9?
I have the same problem with UpgradeModule in my Hybrid Application
image

If you use yarn workspaces or lerna, the error might be related to hoisting. Repro at: https://github.com/angular/angular/issues/35747

The issue is now resolved after upgrading primeng to version ^9.0.0 in package.json.

The issue is now resolved after upgrading primeng to version ^9.0.0 in package.json.

This was my issue, thanks

Closing as compatible PrimeNG version fixes the case.

image

I had also like this issue while working on Angular 9.0.2 with Angular Material.
I'd like to know it can't be resolved with angular material.

This error shows when you add component declaration in imports: [] instead of declarations: [],

e.g:

declarations: [
  AppComponent,
],
imports: [
  BrowserModule,
  AppRoutingModule,
  SomeComponent <-----------wrong
],

Thanks @kumaresan-subramani.
I got solution from your comment.

Thanks @kumaresan-subramani. It was as simple as that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Helayxa picture Helayxa  路  3Comments

lilling picture lilling  路  3Comments

miresk picture miresk  路  3Comments

garethlewis picture garethlewis  路  3Comments

jisqaqov picture jisqaqov  路  3Comments