Angular 5 lazy loading missing path in WebPack

27 views
Skip to first unread message

Toni

unread,
Jun 6, 2018, 10:41:04 AM6/6/18
to Angular and AngularJS discussion
Hi.

I'm try to deploy Angular 5 application with webpack, but when I trying generate WebPack, routes of loadChildren is missing for webpack.

    {
        path: 'Users',
        loadChildren: 'app/Components/Users/Users.module#UsersModule',
        data: { title: 'User List' }
    },

"ERROR in ./app/Navigation/BackOffice.routes.ts Module not found: Error: Can't resolve 'app\Components\Users\Users.module' in ..."

If try change  loadChildren: 'app/Components/Users/Users.module#UsersModule' to loadChildren: '../Components/Users/Users.module#UsersModule' so webpack it works correcly, but not work when run application.

I'm using webpack v3.11.0.

How can I fix this problem?

Thanks.

Sander Elias

unread,
Jun 6, 2018, 10:56:34 AM6/6/18
to Angular and AngularJS discussion
Hi TOni,

Check the baseUrl in your angular.json

Regards
Sander

Toni

unread,
Jun 13, 2018, 9:00:52 AM6/13/18
to Angular and AngularJS discussion
Hi again.

I'n not use angular-cli but I try inserter baseURL in systemjs.config.js but anyway the error persist.

(function (global) {
    System.config({
        baseURL: '/app/',
        transpiler: 'ts',
        meta: {
            'typescript': {"exports": "ts"}
        },
        paths: {
            // paths serve as alias
            'app/*': './app/*',
            'npm:': './node_modules/'
        },


Any more ideas?

Thanks very much.

Toni

unread,
Jun 18, 2018, 2:35:45 AM6/18/18
to Angular and AngularJS discussion
Hi again.

For all persons with a same problem, I found one possible solucion.

In my case change this:

loadChildren: 'app/Components/Users/Users.module#UsersModule',

for 

loadChildren: () => UsersModule,  (need import)

with this change the webpack compile without problem.

Thans very much.


Marvin Cook

unread,
Jul 20, 2018, 11:36:46 PM7/20/18
to Angular and AngularJS discussion
I had the same problem.  I solved it by using a './Components/Users/Users.module#UsersModule'

Hope this helps
Reply all
Reply to author
Forward
0 new messages