Angular 17 ssr build reaching memory limit when routing nested modules

Within my app-module I have three feature modules “desktop”, “info”, “shared”. The desktop-module contains the info-module and the shared-module. The info-module contains a imprint-component and the shared-module contains a foot component:

app
├── desktop
│   ├── desktop-routing.module.ts
│   ├── ...
│   ├── info
│   │   ├── ...
│   │   ├── info-routing.module.ts
│   │   └── imprint
│   │       ├── imprint.component.html
│   │       └── ...
│   └── shared
│       ├── foot
│       │   ├── foot.component.html
│       │   └── ...
│       └── shared-component.module.ts
├── ...
└── app-routing.module.ts

The routes in the app-routing.module are:

const routes: Routes = [
    { path: '', redirectTo: 'desktop', pathMatch: 'full' },
    { path: 'desktop', loadChildren: () => import('./desktop/desktop.module').then(m => m.DesktopVersionModule) }
];

I imported the shared module into the desktop-module and into the info-module. And lazy-load the info-module within desktop-routing.module:

const routes: Routes = [
    { path: '', component: DesktopComponent },
    { path: 'info', loadChildren: () => import('./info/info.module').then(m => m.InfoModule) }
];

where info-routing.module:

const routes: Routes = [
    { path: '', component: InfoComponent,
        children: [
            { path: 'imprint', component: ImprintComponent },
    ]
}];

Both, desktop.component.html and the info.component.html contains the selector <app-foot></app-foot> of the foot-component that includes the foot template into the desktop- and info-template. The foot template contains a link to the imprint-component from the info module:

<span class="default-link" routerLink="info/imprint">Link</span>

If I serve the app, then I can navigate from the desktop-component to the imprint-component by clicking the link in the foot-component. But I can’t navigate from info-component to imprint-component, because the link is not resolved by the framework. To solve it I need to define a shared-routing.module:

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

If I run now ng serve everything is working as expected. But ng build throw exception:

[error] Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to
reaching memory limit: JS heap out of memory
at [kOnExit] (node:internal/worker:313:26)
at Worker..onexit (node:internal/worker:229:20)

How to adjust routing, so that the system will resolve the link correctly and running not into error above during build process?

I already tried to allocate more memory $ node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build, but it doesn’t help.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật