Reputation: 1847
I was reworking my routes by changing them from lazy loaded from a string reference into lazy loaded from a call to import
.
My problem is, every time I navigate to one of the pages, I'm getting the following error message: No NgModule metadata found for '[object Module]'.
consolelogs.js:49 ERROR Error: Uncaught (in promise): Error: No NgModule metadata found for '[object Module]'.
Error: No NgModule metadata found for '[object Module]'.
at NgModuleResolver.resolve (compiler.js:20665)
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:19794)
at JitCompiler._loadModules (compiler.js:25582)
at JitCompiler._compileModuleAndComponents (compiler.js:25565)
at JitCompiler.compileModuleAsync (compiler.js:25527)
at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:216)
at MergeMapSubscriber.wrapIntoObservable.pipe.Object [as project] (router.js:5369)
at MergeMapSubscriber._tryNext (mergeMap.js:46)
at MergeMapSubscriber._next (mergeMap.js:36)
at MergeMapSubscriber.next (Subscriber.js:49)
at NgModuleResolver.resolve (compiler.js:20665)
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:19794)
at JitCompiler._loadModules (compiler.js:25582)
at JitCompiler._compileModuleAndComponents (compiler.js:25565)
at JitCompiler.compileModuleAsync (compiler.js:25527)
at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:216)
at MergeMapSubscriber.wrapIntoObservable.pipe.Object [as project] (router.js:5369)
at MergeMapSubscriber._tryNext (mergeMap.js:46)
at MergeMapSubscriber._next (mergeMap.js:36)
at MergeMapSubscriber.next (Subscriber.js:49)
at resolvePromise (zone-evergreen.js:797)
at resolvePromise (zone-evergreen.js:754)
at zone.scheduleMicroTask (zone-evergreen.js:858)
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:34182)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:469)
at invokeTask (zone-evergreen.js:1603)
What is causing this problem?
Upvotes: 0
Views: 254
Reputation: 1847
It turns out, I was using lazy-loading for my routes but failed to correctly import the module of the page I was loading. Notice the missing call to then()
.
{
path: "references",
children: [
{
path: "",
loadChildren: () =>
import(
"app/applications/requirements/requirements-references/requirements-references.module"
).then(m => m.RequirementsReferencesPageModule)
},
{
path: ":referenceId",
loadChildren: () =>
import(
"app/applications/requirements/requirements-references-detail/requirements-references-detail.module"
)
}
]
}
I missed the then
part of the import. Remember to follow the following pattern:
import("path-to-your-module").then(m => m.NameOfModule)
Upvotes: 1