Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Unable to lazy load modules - Module cannot be found error #1258

@mpalmer-sps

Description

@mpalmer-sps

Hello, I've created a Github repo here: https://github.com/mpalmer-sps/PluralSightNg2Fundamentals

I'm trying to add a module using a lazy load implementation (learning this) but the Angular documented approach does not work despite the syntax being correct. I'm uncertain if this is (maybe) not supported by the SPATemplates?
The error is the following:
ERROR Error: Uncaught (in promise): Error: Cannot find module 'app/user/user.module'. webpackEmptyContext@http://localhost:3258

The user.module is referenced here in the app.module:
{ path: 'user', loadChildren:'app/user/user.module#UsersModule'},

however, this doesn't work even when trying different path strings.

The workaround for this is to modify the navigation link in the navbar.component.html file to the following:
<a [routerLink]="['/profile']" routerLinkActive="active">Welcome User</a>

Whereas before it was the following:
<a [routerLink]="['/user/profile']" routerLinkActive="active">Welcome User</a>

and then removing the path with the loadChildren syntax and adding the UserModule as shown in the app.module.shared.ts file

Is this is expected behavior when using modules other than the app.module?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions