reyesoft / ngx-jsonapi

JSON API client library for Angular 5+ 👌 :: Production Ready 🚀
https://ngx-jsonapi.reyesoft.com/
MIT License
101 stars 52 forks source link

Uncaught Error: Type NgxJsonapiModule does not have 'ɵmod' property. #300

Closed GertjanJ closed 3 years ago

GertjanJ commented 3 years ago

Package looks very promising! Only thing is that I can't use the package with Angular 11. When importing this module the following error appears:

zone-evergreen.js:171 Uncaught Error: Type NgxJsonapiModule does not have 'ɵmod' property.
    at getNgModuleDef (core.js:2124)
    at recurse (core.js:24921)
    at recurse (core.js:24932)
    at registerNgModuleType (core.js:24917)
    at new NgModuleFactory$1 (core.js:25031)
    at compileNgModuleFactory__POST_R3__ (core.js:28586)
    at PlatformRef.bootstrapModule (core.js:28824)
    at HTMLDocument.<anonymous> (main.ts:12)
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Zone.runTask (zone-evergreen.js:167
GertjanJ commented 3 years ago

70% building 588/588 modules 0 active
ERROR in node_modules/ngx-jsonapi/ngx-jsonapi.module.d.ts:4:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the library (ngx-jsonapi) which declares NgxJsonapiModule 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.

GertjanJ commented 3 years ago

Oke so after a lot of searching I found out that there is this thing called ngcc (Angular compatibility compiler). It converts non-ivy libraries into packages ivy can work with.

When adding "postinstall": "ngcc" to scripts in package.json then after each npm install/ng add, all non-ivy packages will be converted. Including this one.

"scripts": {
    "postinstall": "ngcc"
  }