angular-cli: File 'src\main.ts' is missing from the TypeScript compilation.



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



I am running Node v18.17.1 and Angular 17 which I just downloaded yesterday. I created a new project yesterday, it worked fine, went to bed. Got up, went to go keep working on the project, and got the error below (main.ts is missing).

After a while I gave up, decided to just create new project all over again, so I created a new project. (ng new test) and chose scss and no precompile support. When I go to run the project, I get the error again.

- Building...X [ERROR] File 'src\main.ts' is missing from the TypeScript compilation. [plugin angular-compiler]
  Ensure the file is part of the TypeScript program via the 'files' or 'include' property.

Here is my package.json:

  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  "private": true,
  "dependencies": {
    "@angular/animations": "^17.0.0",
    "@angular/common": "^17.0.0",
    "@angular/compiler": "^17.0.0",
    "@angular/core": "^17.0.0",
    "@angular/forms": "^17.0.0",
    "@angular/platform-browser": "^17.0.0",
    "@angular/platform-browser-dynamic": "^17.0.0",
    "@angular/router": "^17.0.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.2"
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.0.1",
    "@angular/cli": "^17.0.1",
    "@angular/compiler-cli": "^17.0.0",
    "@types/jasmine": "~5.1.0",
    "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.2.2"

I’m not sure how to fix this?

Minimal Reproduction

This happens upon creation of a new project for me.

ng new test

When asked, select “SCSS” for CSS, and “No” to the question of precompilation features.

When the project is complete, change to the newly created “test” folder and run

ng s --o

Error appears during build.

Exception or Error

- Building...X [ERROR] File 'src\main.ts' is missing from the TypeScript compilation. [plugin angular-compiler]
  Ensure the file is part of the TypeScript program via the 'files' or 'include' property.

Your Environment

Angular CLI: 17.0.1
Node: 18.17.1
Package Manager: npm 10.2.3
OS: win32 x64

Angular: 17.0.3
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
@angular-devkit/architect       0.1700.1
@angular-devkit/build-angular   17.0.1
@angular-devkit/core            17.0.1
@angular-devkit/schematics      17.0.1
@angular/cli                    17.0.1
@schematics/angular             17.0.1
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else relevant?

This was literally working the evening before. The last thing I did before bed was run the app. I woke up this morning, went to go run it again, and this error appeared.

I would also like to note that I have also tried to uninstall (using npm uninstall, plus I cleared the cache) and reinstall Angular, it made no difference.

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 3
  • Comments: 38 (1 by maintainers)

Most upvoted comments

FYI, still testing, but I think I found the solution (although I can’t explain why it worked yesterday). Adding “preserveSymlinks” in the angular.json file seems to fix the issue.

"architect": {
  "build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
      "preserveSymlinks": true,

Thanks for the confirmation, this will be available on NPM later next week in 17.0.4.

PR that fixes the issue:

We have a tentative fix for this issue, @toddhd or anyone who is experiencing this issue, could you please verify if using a build snapshot fixes the problem when preserveSymlinks is not set?.

npm i --save-dev --force

I get the same behaviour. Did you manage to fix it?

Yes there is progress, after the latest angular patch there are less errors, but rarely I still see this error

I have to do ctrl+c and re-launch ng serve

I’m facing the same problem, only I still get the same error even after setting “preserveSymlinks”: true, but its behavior is strange

  • At the first initialization of ng serve, everything is fine, there is no error
  • Then I change some file and save it.
  • After that moment I get a message in the console with a link to this particular file that I am modifying. image


/* To learn more about this file see: */
    "extends": "./tsconfig.json",
    "compilerOptions": {
        "outDir": "./out-tsc/app",
        "types": [
    "files": [
    "include": [
    "exclude": [

I don’t always have this problem, i.e. the file can be saved and there can be an error.

I use @angular/ssr by default, I don’t know if there is such a bug in spa mode

To be perfectly honest, I have no clue.

But when I see utterly strange behaviour, I would try by reinstalling node.js. I would recommend using NVM.