Skip to content

Error: [vite] cannot find entry point module 'file://...' on Windows with SSR #29424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alan-agius4 opened this issue Jan 20, 2025 · 11 comments · Fixed by #29419
Closed

Error: [vite] cannot find entry point module 'file://...' on Windows with SSR #29424

alan-agius4 opened this issue Jan 20, 2025 · 11 comments · Fixed by #29419
Assignees

Comments

@alan-agius4
Copy link
Collaborator

I updated all my projects to use "@angular/core": "19.1.2" & "@angular/cli": "19.1.3". But now when I start the dev server using "ng serve" and visit the localhost:4200, the nodejs server crashes with the following error:

`
NOTE: Raw file sizes do not reflect development server per-request transformations.
➜ Local: http://localhost:4200/
➜ press h + enter to show help
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^

Error: [vite] cannot find entry point module 'file:///D:/<PROJECT_FOLDER>/.angular/vite-root/spa-near-me/@ng/component?c=src%2Fapp%2Fcomponents%2Fheader%2Fheader.component.ts%40HeaderComponent&t=1737401566323'.
at fetchModule (file:///D:/<PROJECT_FOLDER>/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:51477:13)
at async handleInvoke (file:///D:/<PROJECT_FOLDER>/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:44166:22)
at async EventEmitter.listenerForInvokeHandler (file:///D:/<PROJECT_FOLDER>/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:44239:19) {`

All my projects are using tailwind CSS and I've also enabled provideExperimentalZonelessChangeDetection() .

This problem goes away if I use ng serve --no-hmr.

Here are my dependencies
"dependencies": { "@angular/animations": "^19.1.2", "@angular/common": "^19.1.2", "@angular/compiler": "^19.1.2", "@angular/core": "^19.1.2", "@angular/forms": "^19.1.2", "@angular/platform-browser": "^19.1.2", "@angular/platform-browser-dynamic": "^19.1.2", "@angular/platform-server": "^19.1.2", "@angular/router": "^19.1.2", "@angular/ssr": "^19.1.3", "express": "^4.18.2", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.15.0" }, "devDependencies": { "@angular-devkit/build-angular": "^19.1.3", "@angular/cli": "^19.1.3", "@angular/compiler-cli": "^19.1.2", "@types/express": "^4.17.17", "@types/jasmine": "~5.1.0", "@types/node": "^18.18.0", "autoprefixer": "^10.4.20", "daisyui": "^4.12.23", "jasmine-core": "~5.5.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "lucide-angular": "^0.473.0", "postcss": "^8.5.1", "prettier": "^3.4.2", "tailwindcss": "^3.4.17", "typescript": "~5.7.2", "xmlbuilder": "^15.1.1" }

Originally posted by @rabikr in #59602

@alan-agius4 alan-agius4 self-assigned this Jan 20, 2025
@alan-agius4 alan-agius4 transferred this issue from angular/angular Jan 20, 2025
@alan-agius4 alan-agius4 changed the title Error: [vite] cannot find entry point module 'file:///D:/<PROJECT_FOLDER>/.angular/vite-root/spa-near-me/@ng/component?c=src%2Fapp%2Fcomponents%2Fheader%2Fheader.component.ts%40HeaderComponent&t=1737401566323' on Windows Error: [vite] cannot find entry point module 'file:///D:/<PROJECT_FOLDER>/.angular/vite-root/spa-near-me/@ng/component?c=src%2Fapp%2Fcomponents%2Fheader%2Fheader.component.ts%40HeaderComponent&t=1737401566323'on Windows Jan 20, 2025
@atsjo
Copy link

atsjo commented Jan 21, 2025

similar problem for me... I think 'angular-calendar' is including the problematic import in my repo, never had a problem with it before. It works with latest cli (19.1.3), but not with latest angular (19.1.2). Downgrading angular to 19.1.1 fixes it...

[vite] Pre-transform error: Failed to resolve import "angular-draggable-droppable" from ".angular/vite-root/devtest/main.js". Does the file exist?
Plugin: vite:import-analysis
File: D:/repos/teve-no/task4s/.angular/vite-root/devtest/main.js:6386:23
6384| import * as i79 from "@angular/material/icon";
6385| import * as i87 from "angular-calendar";
6386| import * as i96 from "angular-draggable-droppable";
| ^
6387| import * as i104 from "angular-resizable-element";
6388| function tvCalendarComponent_Case_25_Template(rf, ctx)

@Laffery
Copy link

Laffery commented Jan 21, 2025

+1

alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jan 21, 2025
The `virtualProjectRoot` is normalized, but `sourcePath` is not, leading to mismatched path slashes and related issues.

Closes angular#29424
@Nevada-Way
Copy link

Nevada-Way commented Jan 21, 2025

I created a new deafult app, only ( just html hello ) and when i ran ng serve got same error:
Error: [vite] cannot find entry point module 'file:///D:/0.Create/Angular/ssr-hello/ssrhello/.angular/vite-root/ssrhello/@ng/component?c=src%2Fapp%2Fapp.component.ts%40AppComponent&t=1737451488230'.
at fetchModule (file:///D:/0.Create/Angular/ssr-hello/ssrhello/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:51477:13)
at async handleInvoke (file:///D:/0.Create/Angular/ssr-hello/ssrhello/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:44166:22)
at async EventEmitter.listenerForInvokeHandler (file:///D:/0.Create/Angular/ssr-hello/ssrhello/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:44239:19) {
runnerError: Error: RunnerError
at reviveInvokeError (file:///D:/0.Create/Angular/ssr-hello/ssrhello/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:541:18)
at Object.invoke (file:///D:/0.Create/Angular/ssr-hello/ssrhello/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:624:15)
}

using ng serve --no-hmr bypasses this error because I beleive the source of the issue is in the Hot Module Replacement (HMR)

alan-agius4 added a commit that referenced this issue Jan 21, 2025
The `virtualProjectRoot` is normalized, but `sourcePath` is not, leading to mismatched path slashes and related issues.

Closes #29424

(cherry picked from commit abb186a)
@clydin clydin changed the title Error: [vite] cannot find entry point module 'file:///D:/<PROJECT_FOLDER>/.angular/vite-root/spa-near-me/@ng/component?c=src%2Fapp%2Fcomponents%2Fheader%2Fheader.component.ts%40HeaderComponent&t=1737401566323'on Windows Error: [vite] cannot find entry point module 'file://...' on Windows Jan 21, 2025
@clydin clydin changed the title Error: [vite] cannot find entry point module 'file://...' on Windows Error: [vite] cannot find entry point module 'file://...' on Windows with SSR Jan 21, 2025
@ahmedmohamedrashad01
Copy link

ahmedmohamedrashad01 commented Jan 22, 2025

I have the same issue, but if I run this command ng s -o --no-hmr
the app is working fine without any issue

@quedicesebas
Copy link

Not fixed for me.

@alan-agius4
Copy link
Collaborator Author

@quedicesebas please provide the output of ng version.

@quedicesebas
Copy link

@quedicesebas please provide the output of ng version.

Angular CLI: 19.1.4
Node: 20.15.0
Package Manager: npm 10.8.1
OS: win32 x64

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

Package Version

@angular-devkit/architect 0.1702.3
@angular-devkit/build-angular 19.1.4
@angular-devkit/core 17.2.3
@angular-devkit/schematics 19.1.4
@angular/cli 19.1.4
@angular/fire 19.0.0
@angular/google-maps 19.1.1
@angular/ssr 19.1.4
@schematics/angular 19.1.4
rxjs 7.8.1
typescript 5.6.3
zone.js 0.15.0

But correction. The error is not shown, but the app is not loading, showing Cannot GET / in the browser. If I press F5 (reload), loads normally :S

@alan-agius4
Copy link
Collaborator Author

@quedicesebas, that seems unrelated to this, we haven’t had similar reports. Please file a new issue with a minimal reproduction. Thanks.

@gnibeda
Copy link

gnibeda commented Jan 27, 2025

Maybe I have a different case. I need SSR only for prod build, but not in dev mode.
In my case I've got the same error due to CLI trying to access src/main.server.ts with disabled SSR.

Solved it by moving "server": "src/main.server.ts", to production configuration.

Details:
in angular.json I've set ssr to false for development configuration:

"development": {
    "ssr": false,

CLI still tries to access src/main.server.ts (why in the name of god, if ssr is disabled in configuration???)

So I've moved "server": "src/main.server.ts", from architect/build/options to architect/build/configurations/production.
Now ng serve works fine and doesn't try to access src/main.server.ts.

@CarlosTorrecillas
Copy link
Contributor

@gnibeda Thanks, that worked for me! It looks like if you have disabled SSR you have to move the related configuration to the section that is really using it, PROD. I had the exact same use case and it now works

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants