Cannot read property 'visitExpression' of undefined

In my case, it was components with empty selectors.


In my case, it was duplicate , in the Routes array in app.routing.ts.

You can use ,[\s]*, as a Regular Expression search query to find it in your routes to find two commas with (0 to many) white spaces in between them.


For me it was ,, in the *-routing.module.ts

   path: 'shoplist',
    children: [
      {
        path: '',
        loadChildren: () => import('../shoplist/shoplist.module').then(m => m.ShoplistModule)
      }
    ]
  },, <------------------ this was the cause
  {
    path: 'notification',
    children: [
      {
        path: '',
        loadChildren: () => import('../notification/notification.module').then(m => m.NotificationModule)
      }
    ]
  },

It was ',' in my case in app.module.ts file.

imports: [
    BrowserModule,
    **AppRoutingModule,,**
    HttpClientModule,

Changed it to:

imports: [
    BrowserModule,
    **AppRoutingModule,**
    HttpClientModule,