Unable to extract routes from application while pre rendering angular app

Viewed 1128

I'm trying to implement pre rendering in angular app version 11.

After running the command npm run prerender I'm getting the below error

Unable to extract routes from application.

My App Module

const routes: Routes = [
  {
    path: '',
    loadChildren: () => import('./pages/pages.module').then(m => m.PagesModule),
  }
];

PagesModule

const routes: Routes = [
  {
    path: '',
    component: PageComponent,
    children: [
      {
        path: '',
        loadChildren: () => import('./home-page/home-page.module').then(m => m.HomePageModule),
      },
      {
        path: 'about',
        component: AboutComponent
      },
      {
        path: 'tariff',
        component: TariffComponent
      },
      {
        path: 'contact',
        component: ContactComponent
      }
    ]
  }
];

I created a routes.txt file and added the following lines

/about
/traiff
/contact

In angular.json file,

    "prerender": {
      "builder": "@nguniversal/builders:prerender",
      "options": {
        "browserTarget": "newTaxi:build:production",
        "serverTarget": "newTaxi:server:production",
        "routesFile": "./routes.txt"
      },
      "configurations": {
        "production": {}
      }
    }

What I'm doing wrong here ? please guide me

0 Answers
Related