Angular 4 - Could not resolve submodule for routing
I was using the absolute path convention: app/home#HomeModule
and it wasn't working.
I then tried the relative path convention: ./home#HomeModule
and it worked.
... in the CLI, the paths to lazy routes should be relative from the file you're in
Source
I followed this Tutorial and it used the absolute path convention and it worked.
Would love to know why the inconsistency...
UPDATE:
As Friedrich mentioned, to make it work using an Absolute Path, update src/tsconfig.app.json
as follows:
{
...,
"compilerOptions": {
...,
baseUrl: "./"
}
}
I had the same issue and none of the answers above worked for me,the final solution i found was using the absolute path of the module and module class name after the '#'.
export const ROUTES: Routes = [
{path: '', loadChildren: 'src/app/pathToYourModule/home.module#HomeModule'},
{path: '**', component: NotFoundComponent}
];
I started the path from 'src' and dont forget to remove the '.ts' from the module path.