diff --git a/packages/router/src/router_module.ts b/packages/router/src/router_module.ts index 13d6665e9ef..803fb2de477 100644 --- a/packages/router/src/router_module.ts +++ b/packages/router/src/router_module.ts @@ -181,7 +181,8 @@ export function provideForRootGuard(router: Router): any { if (NG_DEV_MODE && router) { throw new RuntimeError( RuntimeErrorCode.FOR_ROOT_CALLED_TWICE, - `RouterModule.forRoot() called twice. Lazy loaded modules should use RouterModule.forChild() instead.`); + `The Router was provided more than once. This can happen if 'forRoot' is used outside of the root injector.` + + ` Lazy loaded modules should use RouterModule.forChild() instead.`); } return 'guarded'; } diff --git a/packages/router/test/integration.spec.ts b/packages/router/test/integration.spec.ts index b07b0b36975..12cafce2b79 100644 --- a/packages/router/test/integration.spec.ts +++ b/packages/router/test/integration.spec.ts @@ -5806,7 +5806,7 @@ describe('Integration', () => { let recordedError: any = null; router.navigateByUrl('/lazy/loaded')!.catch(err => recordedError = err); advance(fixture); - expect(recordedError.message).toContain(`RouterModule.forRoot() called twice.`); + expect(recordedError.message).toContain(`NG04007`); }))); it('should combine routes from multiple modules into a single configuration',