Skip to content

Dev Server throws error when running Angular 17 app non-standalone with SSR #26922

@griest024

Description

@griest024

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

16

Description

When running an Angular 17 app with the module setup and SSR enabled, the dev server throws an error.

Building (ng b) works (unless prerender: true) and serving the client bundle directly works as well as running SSR: node dist/repro-app/server/server.mjs.

With prerender enabled, building throws the same error as the dev server.

Removing SSR (deleting ssr and server options in angular.json) causes the dev server to work as expected.

Minimal Reproduction

Run ng s in my repro.

See this branch for a repro of how removing SSR options fixes the issue.

Exception or Error

[vite] Internal server error: Cannot read properties of undefined (reading 'ɵmod')
      at getNgModuleDef (/workspace/repro-app/node_modules/@angular/core/fesm2022/core.mjs:2117:25)
      at assertNgModuleType (/workspace/repro-app/node_modules/@angular/core/fesm2022/core.mjs:2371:10)
      at compileNgModuleFactory (/workspace/repro-app/node_modules/@angular/core/fesm2022/core.mjs:31582:18)
      at _PlatformRef.bootstrapModule (/workspace/repro-app/node_modules/@angular/core/fesm2022/core.mjs:32472:16)
      at eval (/workspace/repro-app/node_modules/@angular/platform-server/fesm2022/platform-server.mjs:17111:39)
      at Generator.next (<anonymous>)
      at eval (/workspace/repro-app/.angular/vite-root/repro-app/chunk-VPSODEBW.mjs:64:61)
      at ZoneAwarePromise (/workspace/repro-app/node_modules/zone.js/fesm2015/zone-node.js:1353:21)
      at Module.__async (/workspace/repro-app/.angular/vite-root/repro-app/chunk-VPSODEBW.mjs:48:10)
      at renderModule (/workspace/repro-app/node_modules/@angular/platform-server/fesm2022/platform-server.mjs:17100:50)

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.1.0
Node: 18.19.0
Package Manager: npm 10.2.3
OS: linux x64

Angular: 17.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1701.0
@angular-devkit/build-angular   17.1.0
@angular-devkit/core            17.1.0
@angular-devkit/schematics      17.1.0
@schematics/angular             17.1.0
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.3

Anything else relevant?

Maybe this isn't a supported usage since standalone is default now? Seems like modules should still be fully supported until they're officially deprecated.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions