core.js:27296 Uncaught TypeError: Cannot read properties of undefined (reading 'ngModule')
at isModuleWithProviders (core.js:27296)
at expandModuleWithProviders (core.js:27290)
at Array.map (<anonymous>)
at Function.get (core.js:26927)
at getNgModuleDef (core.js:1117)
at assertNgModuleType (core.js:1296)
at compileNgModuleFactory__POST_R3__ (core.js:29073)
at PlatformRef.bootstrapModule (core.js:29324)
at Module.14431 (main.ts:11)
at __webpack_require__ (bootstrap:19)
I have a custom library that is consumed by the main project (app). Everything was fine until I updated the project to Angular 12.
I followed the update instructions here, for both the main project and the custom library
There are no compile errors when I serve and no build errors when I build with --prod flag. However, when I try to assess the app locally from the browser I get the above error.
I have tried debugging it. That led me to these solutions, here and here. With those, I was able to trace the error to the modules imported from the custom library. But that's where I'm stuck.
Please, can someone assist with how to fix the error and run the app?
App.module
import { UtilsModule } from '@utils/utils.module';
import { PipesModule } from '@pipes/pipes.module';
...
@NgModule({
imports: [
BrowserModule,
...
PipesModule,
UtilsModule
]
})
tsconfig.json
{
"paths": {
...
"@pipes/*": [
"./node_modules/custom-library/src/pipes/*"
],
"@utils/*": [
"./node_modules/custom-library/src/utils/*"
],
...
}
...
}
package.json
{
...
"dependencies": {
...
"custom-library": "url-to-repository-branch"
...
}
...
}
The library was installed with this approach here