'When I do ng serve it gives me an error of maximun call stack size exceeded

I have a project folder with the next parts: User and Artist It is suppose to be a multi app.

artists app.module


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    DashboardModule,
 SharedModule,
 HttpClientModule,
 ToastrModule.forRoot(),
  ],
  providers: [
    {provide: APP_BASE_HREF, useValue: '/'},

    {
        provide:HTTP_INTERCEPTORS,
        useClass: HttpErrorInterceptorService,
        multi: true
    },
    AlertifyService,
    AuthService,
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

@NgModule({})
export class App2SharedModule {
  static forRoot(): ModuleWithProviders<AppModule>{
    return {
      ngModule: AppModule,
      providers: []
    };
  }
}

user app.module

 App2SharedModule.forRoot()

user app-roting

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { App2SharedModule } from '../../../artists/src/app/app.module';

const routes: Routes = [
  { path: 'auth', loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule)},
  { path: 'artists', loadChildren: () => import('../../../artists/src/app/app.module').then(m => m.App2SharedModule)},

];

@NgModule({
  imports: [RouterModule.forRoot(routes),App2SharedModule.forRoot()],
  exports: [RouterModule]
})
export class AppRoutingModule { }

When I run ng serve it shows the next error:

Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js): Error: Maximum call stack size exceeded 

Does anyone knows how to solve this kind of errors? And if so, could you tell me whats wrong on my code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source