Skip to content

Angular CLI 19.0.0-next.9 only works in SSR mode #28556

@e-oz

Description

@e-oz

Which @angular/* package(s) are the source of the bug?

compiler-cli

Is this a regression?

Yes

Description

I apologize for the bug report without a reproduction link.
It is posted in the hope that you might get some clues about what could be wrong just by reading the error and config.

With this config:

"build": {
  "executor": "@angular-devkit/build-angular:application",
    "outputs": [
    "{options.outputPath}"
  ],
    "options": {
    "outputPath": "dist/apps/app-name",
      "index": "apps/app-name/src/index.html",
      "browser": "apps/app-name/src/main.ts",
      "polyfills": [
      "@angular/localize/init"
    ],
      "statsJson": true,
      "tsConfig": "apps/app-name/tsconfig.app.json",
      "inlineStyleLanguage": "scss",
      "localize": true,
      "assets": [
      {
        "glob": "**/*",
        "input": "apps/app-name/public"
      }
    ],
      "styles": [
      "apps/app-name/src/styles.scss"
    ],
      "scripts": [],
      "prerender": {
      "discoverRoutes": false,
        "routesFile": "apps/app-name/routes.txt"
    },
    "server": "apps/app-name/src/main.server.ts",
      "ssr": false
  },
  "configurations": {
    "production": {
      "budgets": [
        {
          "type": "initial",
          "maximumWarning": "500kb",
          "maximumError": "1mb"
        },
        {
          "type": "anyComponentStyle",
          "maximumWarning": "10kb",
          "maximumError": "20kb"
        }
      ],
        "outputHashing": "all",
        "fileReplacements": [
        {
          "replace": "apps/app-name/src/environments/environment.ts",
          "with": "apps/app-name/src/environments/environment.prod.ts"
        }
      ],
        "serviceWorker": "apps/app-name/ngsw-config.json"
    },
    "development": {
      "optimization": false,
        "extractLicenses": false,
        "sourceMap": true,
        "ssr": false,
        "prerender": false
    },
    "dev-ssr": {
      "optimization": false,
        "extractLicenses": false,
        "sourceMap": true
    }
  },
  "defaultConfiguration": "production"
},
"serve": {
  "executor": "@angular-devkit/build-angular:dev-server",
    "configurations": {
    "production": {
      "buildTarget": "app-name:build:production"
    },
    "development": {
      "buildTarget": "app-name:build:development"
    },
    "dev-ssr": {
      "buildTarget": "app-name:build:dev-ssr"
    }
  },
  "defaultConfiguration": "development"
},
"serve-ssr": {
  "executor": "@angular-devkit/build-angular:dev-server",
    "configurations": {
    "development": {
      "buildTarget": "app-name:build:dev-ssr"
    }
  },
  "defaultConfiguration": "development"
}

ng serve throws an error, and ng serve --configuration=dev-ssr works fine

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

NOTE: Raw file sizes do not reflect development server per-request transformations.
➜ Local: http://localhost:4200/
➜ press h + enter to show help
5:48:55 PM [vite] Internal server error: Failed to load url /main.server.mjs (resolved id: /main.server.mjs). Does the file exist?
at loadAndTransform (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51858:17)
at async instantiateModule (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52817:44)
5:48:55 PM [vite] Internal server error: Failed to load url /main.server.mjs (resolved id: /main.server.mjs). Does the file exist?
at loadAndTransform (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51858:17)
at async instantiateModule (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52817:44) (x2)
5:49:00 PM [vite] Internal server error: Failed to load url /main.server.mjs (resolved id: /main.server.mjs). Does the file exist?
at loadAndTransform (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51858:17)
at async instantiateModule (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52817:44) (x3)
5:49:01 PM [vite] Internal server error: Failed to load url /main.server.mjs (resolved id: /main.server.mjs). Does the file exist?
at loadAndTransform (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51858:17)
at async instantiateModule (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52817:44) (x4)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.0.0-next.9
Node: 22.9.0
Package Manager: npm 10.8.3
OS: darwin arm64

Angular: 19.0.0-next.8
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package Version

@angular-devkit/architect 0.1900.0-next.9
@angular-devkit/build-angular 19.0.0-next.9
@angular-devkit/core 19.0.0-next.9
@angular-devkit/schematics 19.0.0-next.9
@angular/cdk 19.0.0-next.6
@angular/cli 19.0.0-next.9
@angular/material 19.0.0-next.6
@angular/pwa 19.0.0-next.9
@angular/ssr 19.0.0-next.9
@schematics/angular 19.0.0-next.9
rxjs 7.8.1
typescript 5.6.2
zone.js 0.15.0

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions