Closed as duplicate
Closed as duplicate
Copy link
Description
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
No response
Description
When implementing lazy loading routes, the application fails during runtime with the following error:
上午10:49:31 [vite] Internal server error: ɵgetOrCreateAngularServerApp is not a function
at C:\Project\ssrtest\node_modules\.pnpm\@[email protected]_@angu_5cd6b3085b9f53655a442b950631221f\node_modules\@angular\build\src\tools\vite\middlewares\ssr-middleware.js:26:38
上午10:49:31 [vite] Pre-transform error: Failed to resolve import "./chunk-LPMLDZGR.js" from ".angular/vite-root/ssrtest/main.js". Does the file exist?
Plugin: vite:import-analysis
File: C:/Project/ssrtest/.angular/vite-root/ssrtest/main.js:6:31
14 | __spreadValues({
15 | path: "",
16 | loadChildren: () => import("./chunk-LPMLDZGR.js")
| ^
17 | }, false ? { \u0275entryName: "src/app/test/lazy.route.ts" } : {})
18 | ];
上午10:49:31 [vite] Internal server error: Failed to resolve import "./chunk-LPMLDZGR.js" from ".angular/vite-root/ssrtest/main.js". Does the file exist?
Plugin: vite:import-analysis
File: C:/Project/ssrtest/.angular/vite-root/ssrtest/main.js:6:31
14 | __spreadValues({
15 | path: "",
16 | loadChildren: () => import("./chunk-LPMLDZGR.js")
| ^
17 | }, false ? { \u0275entryName: "src/app/test/lazy.route.ts" } : {})
18 | ];
at TransformPluginContext._formatError (file:///C:/Project/ssrtest/node_modules/.pnpm/[email protected]_@[email protected]_7931a348c589a4516c328719e7197a02/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:47397:41)
at TransformPluginContext.error (file:///C:/Project/ssrtest/node_modules/.pnpm/[email protected]_@[email protected]_7931a348c589a4516c328719e7197a02/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:47392:16)
at normalizeUrl (file:///C:/Project/ssrtest/node_modules/.pnpm/[email protected]_@[email protected]_7931a348c589a4516c328719e7197a02/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:45642:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///C:/Project/ssrtest/node_modules/.pnpm/[email protected]_@[email protected]_7931a348c589a4516c328719e7197a02/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:45761:39
Minimal Reproduction
Steps to reproduce the issue:
- Create a new Angular project with SSR using version 19.1.0 or 19.1.1
- Configure routes using loadChildren
- Run the server
- Change component HTML template
- Observe the error in the terminal.
Reproduction project: https://github.com/Ruisi-Lu/angular19.1-lazyload-route-bug-reproduction-
Exception or Error
Your Environment
Angular CLI: 19.1.1
Node: 20.18.1
Package Manager: pnpm 10.0.0
OS: win32 x64
Angular: 19.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1901.1
@angular-devkit/build-angular 19.1.1
@angular-devkit/core 19.1.1
@angular-devkit/schematics 19.1.1
@schematics/angular 19.1.1
rxjs 7.8.1
typescript 5.7.3
zone.js 0.15.0
Anything else relevant?
No response
Metadata
Metadata
Assignees
Labels
No labels
Activity
pisxid commentedon Jan 17, 2025
Also happens without SSR. Hot reload is not working
anisabboud commentedon Jan 21, 2025
Still seeing this issue with @angular/cli
19.1.3released yesterday.(Happens randomly when saving a file.)
alan-agius4 commentedon Jan 21, 2025
@anisabboud, the issue you're reporting is unrelated to this one. Please submit a new issue with the steps to reproduce. Thank you.
enzofrnt commentedon Feb 4, 2025
I'm still getting this error :
It appears when I add something to any component of my app.
Ahmed-Makled commentedon Feb 16, 2025
any soltuions ?
chiragmer77 commentedon Feb 19, 2025
any soltuions ?
adnanibrahem commentedon Feb 22, 2025
try this:
constructor(@Inject(DOCUMENT) document: Document) { }
Kgermando commentedon Mar 16, 2025
04:00:03 [vite] Internal server error: ɵgetOrCreateAngularServerApp is not a function
at C:\Users\germa\Documents\DEVELOPER\ANGULAR\PROJECTS\optimatincorporation\node_modules@angular\build\src\tools\vite\middlewares\ssr-middleware.js:30:38
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
04:00:06 [vite] Internal server error: ɵgetOrCreateAngularServerApp is not a function
at C:\Users\germa\Documents\DEVELOPER\ANGULAR\PROJECTS\optimatincorporation\node_modules@angular\build\src\tools\vite\middlewares\ssr-middleware.js:30:38
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) (x2)
angular-automatic-lock-bot commentedon Apr 16, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.