Skip to content

Error When Running ng serve Since Version 18.1.0-next.1 : Pre-transform error: Failed to load url ./main.server.mjs (resolved id: ./main.server.mjs). Does the file exist #27907

Closed
@naveedahmed1

Description

@naveedahmed1

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

Since version 18.1.0-next.1 I am receiving the below error when running ng serve, whereas ng serve --configuration production seems to be working fine.

9:37:49 pm [vite] Pre-transform error: Failed to load url ./main.server.mjs (resolved id: ./main.server.mjs). Does the file exist?

Below is my package.json file:

"dependencies": {
    "@angular/animations": "18.1.0-next.3",
    "@angular/cdk": "18.1.0-next.3",
    "@angular/common": "18.1.0-next.3",
    "@angular/compiler": "18.1.0-next.3",
    "@angular/core": "18.1.0-next.3",
    "@angular/fire": "18.0.1",
    "@angular/forms": "18.1.0-next.3",
    "@angular/google-maps": "18.1.0-next.3",
    "@angular/material": "18.1.0-next.3",
    "@angular/platform-browser": "18.1.0-next.3",
    "@angular/platform-browser-dynamic": "18.1.0-next.3",
    "@angular/platform-server": "18.1.0-next.3",
    "@angular/pwa": "18.1.0-next.3",
    "@angular/router": "18.1.0-next.3",
    "@angular/service-worker": "18.1.0-next.3",
    "@fingerprintjs/fingerprintjs": "3.4.0",
    "@ngx-pwa/local-storage": "18.0.0",
    "@swimlane/ngx-charts": "20.5.0",
    "@zootools/email-spell-checker": "1.12.0",
    "d3-shape": "1.3.7",
    "dayjs": "^1.11.9",
    "easy-speech": "^2.3.1",
    "event-source-polyfill": "1.0.31",
    "file-saver": "2.0.5",
    "firebase": "10.12.2",
    "ng-recaptcha": "13.2.1",
    "ng2-adsense": "14.0.0",
    "ng2-ckeditor": "1.3.7",
    "ngx-img-cropper": "14.0.1",
    "ngx-infinite-scroll": "18.0.0",
    "ngx-stripe": "18.1.0",
    "rxjs": "~7.8.0",
    "screenfull": "5.0.2",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "18.1.0-next.3",
    "@angular/cli": "18.1.0-next.3",
    "@angular/compiler-cli": "18.1.0-next.3",
    "@cloudflare/workers-types": "4.20240405.0",
    "@miniflare/tre": "3.0.0-next.14",
    "@types/express": "^4.17.17",
    "@types/jasmine": "~5.1.0",
    "@types/node": "^18.18.0",
    "@types/webappsec-credential-management": "^0.6.5",
    "concat": "3.0.0",
    "html-minifier-terser": "^5.1.1",
    "jasmine-core": "~5.1.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",
    "typescript": "~5.4.5",
    "wrangler": "^3.48.0"
  }

Minimal Reproduction

@alan-agius4 you can reproduce it in the private repo I have shared earlier.

Exception or Error

`9:37:49 pm [vite] Pre-transform error: Failed to load url ./main.server.mjs (resolved id: ./main.server.mjs). Does the file exist?`

Your Environment

Angular CLI: 18.1.0-next.3
Node: 20.12.2
Package Manager: npm 10.6.0
OS: win32 x64

Angular: 18.1.0-next.3
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, google-maps, material, platform-browser
... platform-browser-dynamic, platform-server, pwa, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.0-next.3
@angular-devkit/build-angular   18.1.0-next.3
@angular-devkit/core            18.0.2
@angular-devkit/schematics      18.0.2
@angular/fire                   18.0.1
@schematics/angular             18.0.2
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.4

Anything else relevant?

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