Cannot read property 'visitExpression' of undefined

AngularTypescript

Angular Problem Overview


In my angular app at the startup point I'm facing this error:

Cannot read property visitExpression of undefined

What could be the problem?

Angular Solutions


Solution 1 - Angular

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.

Solution 2 - Angular

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

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

Changed it to:

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

Solution 3 - Angular

In my case, it was components with empty selectors.

Solution 4 - Angular

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)
      }
    ]
  },

Solution 5 - Angular

I did a global find and replace all with ,[\s]*, and replaced it with ,. The double comma was found in multiple other module imports which is what was breaking my app.

Solution 6 - Angular

in my case it was a missing } after a pipe, within an 'else' ng-template within a mat-tab:

<mat-tab [label]="'PHOTOS' | transloco">
  <div *ngIf="images.length; else noPhoto">
    ...
  </div>
  <ng-template #noPhoto>
    <div>
      {{ "NO_PHOTOS" | transloco } <------------------ this was the cause
    </div>
  </ng-template>
</mat-tab>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEleView Question on Stackoverflow
Solution 1 - AngularhagayView Answer on Stackoverflow
Solution 2 - AngularSai SView Answer on Stackoverflow
Solution 3 - AngularEleView Answer on Stackoverflow
Solution 4 - AngularSrijib MandalView Answer on Stackoverflow
Solution 5 - AngularRuanBuitendagView Answer on Stackoverflow
Solution 6 - AngularStephenView Answer on Stackoverflow