angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

WARNING in Duplicated path in loadChildren detected during a rebuild

Open arnaudoisel opened this issue 8 years ago • 27 comments

Versions

Angular CLI: 1.5.0
Node: 8.9.1
OS: win32 x64
Angular: 5.0.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.34
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.38
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.8
typescript: 2.4.2
webpack: 3.8.1

Repro steps

  • Checkout the project : https://github.com/arnaudoisel/lazy-loading-routes-bug
  • > yarn (or npm install)
  • > ng serve
  • Modify the "routes.ts" file (by adding a comment for example)
  • Save the file => The warning will be displayed in the console

Observed behavior

With Angular CLI, if a project contains a module that is lazy loaded, when we modify the file containing the routes, after the automatic rebuild by Angular CLI, the following warning message is displayed in the console :

WARNING in Duplicated path in loadChildren detected during a rebuild. We will take the latest version detected and override it to save rebuild time. You should perform a full build to validate that your routes don't overlap.

Desired behavior

Desired : No warning message displayed in console.

Otherwise it might cause bugs while developping. And even without any real issue, the warning message is a bit scary and could prevent from acknowledging real bugs in the application.

arnaudoisel avatar Dec 02 '17 13:12 arnaudoisel

node 9.1.0 angular-cli 1.5.5 loadChildren.....

wkylin avatar Dec 05 '17 14:12 wkylin

I find this warning confusing. It does not specify which routes were overlapping or for which paths. It is also unclear to me what the CLI is doing to save rebuild time. I appreciate that this warning his here but I'm not sure what to do about it or how likely it is a problem.

I'm seeing this warning twice per build, probably because it is checked by two systems:

https://github.com/angular/angular-cli/blob/4b0c7a35359effc1d93cd3bb5ddc5c441b3cf154/packages/%40ngtools/webpack/src/angular_compiler_plugin.ts#L448-L455

https://github.com/angular/angular-cli/blob/6984cc2b68dac568255fd27e8ec84d53052ea6c3/packages/%40ngtools/webpack/src/plugin.ts#L319-L325

aciccarello avatar Dec 11 '17 19:12 aciccarello

same error here: image

elvisbegovic avatar Dec 12 '17 07:12 elvisbegovic

same issue

JuliaRakitina avatar Dec 12 '17 11:12 JuliaRakitina

Warnings also exist in Angular CLI: 1.6.0

dylanjmcdonald avatar Dec 13 '17 16:12 dylanjmcdonald

Yep, same issue, project builds and runs but it would be nice to understand why (no routes overlap in my config), very yellow and annoying

Fiontan avatar Dec 14 '17 15:12 Fiontan

I also get a lot of yellow warnings but I think I found my issue.

In my layout routes:

const routes: Routes = [
    {
        path: '',
        component: LayoutComponent,
        children: [
            { path: '', redirectTo: 'dashboard' },
            { path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' },
            { path: 'charts', loadChildren: './charts/charts.module#ChartsModule' },
            { path: 'tables', loadChildren: './tables/tables.module#TablesModule' },
            { path: 'forms', loadChildren: './form/form.module#FormModule' },
            { path: 'bs-element', loadChildren: './bs-element/bs-element.module#BsElementModule' },
            { path: 'grid', loadChildren: './grid/grid.module#GridModule' },
            { path: 'components', loadChildren: './bs-component/bs-component.module#BsComponentModule' },
            { path: 'blank-page', loadChildren: './blank-page/blank-page.module#BlankPageModule' },
            { path: 'order', loadChildren: './order/order.module#OrderModule' },
            { path: 'threed', loadChildren: './threed/threed.module#ThreedModule'}
        ]
    }
];

If I add a , after the last one like this { path: 'threed', loadChildren: './threed/threed.module#ThreedModule'}, then it will dump several lines of yellow saying duplicates just like @istiti.

Make sure you stop ng serve and start it again. Once the yellow is there it will still show if you make the change without stopping ng serve.

pbrink231 avatar Dec 15 '17 16:12 pbrink231

Warnings also exist in Angular CLI: 1.6.1

zngong avatar Dec 21 '17 11:12 zngong

And in "@angular/cli": "1.6.2",

MiroKov avatar Dec 21 '17 16:12 MiroKov

And in "@angular/cli": "1.6.3",

RainingNight avatar Jan 03 '18 06:01 RainingNight

Hi, I am also facing the same, Is there any solution you guys found or any workaround ?

prvn3294 avatar Jan 12 '18 19:01 prvn3294

This warning seems to be a red herring. Stopping and restarting "ng serve" seems to fix the warning almost all the time.

I really dislike this indeterminism because I don't know if there is something wrong with my app (in this case routes - which might be serious if the warning is real).

I noticed some errors also disappear after I restart 'ng serve' especially when I reorganize my code in modules, I see tonnes of errors - which disappear after a restart of 'ng serve'

Restarting "ng serve" not showing the warnings and errors anymore makes Angular look flaky. I hope things get better in future revisions

kotpal avatar Jan 12 '18 20:01 kotpal

Solution suggested by @pbrink231 worked for me. I also had a rogue comma at the end of my last route and removing it fixed the issue.

If I add a , after the last one like this { path: 'threed', loadChildren: './threed/threed.module#ThreedModule'}, then it will dump several lines of yellow saying duplicates just like @istiti.

Make sure you stop ng serve and start it again. Once the yellow is there it will still show if you make the change without stopping ng serve.

Rory-Gaddin avatar Jan 22 '18 13:01 Rory-Gaddin

And in "@angular/cli":"1.6.5"

candy4290 avatar Jan 25 '18 08:01 candy4290

It occurs with the following steps (in my scenario) @angular/cli: 1.6.6

  1. make sure ng serve is not running
  2. add a bug to one of your components (save)
  3. ng serve
  4. should get a red line error

ERROR in {your ts file}

webpack: failed to compile` webpack: Compiling... 12% building modules ..... ERROR in {your ts file}

Date - Hash - Time 3 unchanged chunks {chunk list}

Warning in Duplicated path....don't overlap

  1. fix error and save

webpack: Compiled with warnings. webpack: Compiling... Date: 2018-01-30T13:50:38.087Z - Hash: 8cdce4afb09eb7f31a1d - Time: 954ms 11 unchanged chunks chunk {YOUR.module} YOUR.module.chunk.js () 110 kB [rendered]

It looks like CLI is reverting back to the last successful build. Is that true? Cant seem to find an option on ng serve to just let it fail.

elAndyG avatar Jan 30 '18 14:01 elAndyG

Failed to compile.

Error: Duplicated path in loadChildren detected: "./equipment-children.module#EquipmentChildrenModule" is used in 2 loadChildren, but they point to different modules "(/home/www/angular/app/admin/equipment/equipment-children.module.ts and "/home/www/angular/app/admin/equipment/equipment/equipment-children.module.ts"). Webpack cannot distinguish on context and would fail to load the proper one.
    at /home/www/node_modules/@angular/compiler-cli/src/ngtools_api.js:59:23
    at Array.forEach (<anonymous>)
    at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/home/www/node_modules/@angular/compiler-cli/src/ngtools_api.js:55:20)
    at AngularCompilerPlugin._getLazyRoutesFromNgtools (/home/www/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:248:66)
    at Promise.resolve.then.then (/home/www/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:565:50)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

default

repertory avatar Feb 01 '18 07:02 repertory

I put log in @ngtools/[email protected]/src/angular_compiler_plugin.js. Here is an issue: if (this._lazyRoutes[moduleKey] !== modulePath). It seems path separator slashes don't match each other. _lazyRoutes uses / and modulePath uses \. lazyRouter: D:/products/nes-web3/nes-web-beta/apps/nes/src/app/login/login.module.ts modulePath: D:\products\nes-web3\nes-web-beta\apps\nes\src\app\login\login.module.ts

batdelger avatar Feb 05 '18 07:02 batdelger

About the error: "WARNING in Duplicated path in loadChildren detected during a rebuild"... I managed to fix this by adding the full path to the loadChildren string.

I changed the string './orders/orders.module#OrdersModule' to 'app/orders/orders.module#OrdersModule'.

Now the error has gone, I think that this occurs because of the atribute string having the same 'initial' path of the loadChildren...

Before (with error): { path: 'orders', loadChildren: './orders/orders.module#OrdersModule'} Now: { path: 'orders', loadChildren: 'app/orders/orders.module#OrdersModule'}

frederikocmr avatar Feb 15 '18 17:02 frederikocmr

I did the same as @frederikocmr did and it works like a charm! One must use the absolute path.

patrickgdl avatar Feb 20 '18 20:02 patrickgdl

@frederikocmr it works thanks .

zinderud avatar Feb 25 '18 22:02 zinderud