简体   繁体   中英

Angular 13.2. error: Add only entry points to the 'files' or 'include' properties in your tsconfig

I've an issue that as per subjected above.

Yesterday wasn't show any problem when calling ng serve on my project. But today it's shows the error.

I'm trying to resolve and find out on google/stackoverflow still unlucky even follow the solutions on every pages suggested such as must edit on tsconfig.app.json include exclude part.

Until clean install all of nodejs, npm, angular-cli including removing the directory installer even using the latest angular 14.2. but the issue still appear.

Testing with fresh create new project without any component [using standard ng new] (ng new test33) then run (ng serve) still showing the problem.

testing environment version:

windows: 10.0.19044.1766

nodes: 16.14.0, 16.17.1, 18.10.0

npm: ( package from nodes )

angular-cli: 13.2.0 - 14.2

But the issue still appear.


C:\Users\THG\My Documents\apps\test33>ng serve
√ Browser application bundle generation complete.

Initial Chunk Files   | Names         |  Raw Size
styles.css, styles.js | styles        | 175.24 kB |
polyfills.js          | polyfills     | 174.53 kB |
vendor.js             | vendor        | 173.64 kB |
runtime.js            | runtime       |   6.51 kB |
main.js               | main          |   1.02 kB |

                      | Initial Total | 530.95 kB

Build at: 2022-10-05T04:17:55.815Z - Hash: a99455c1b2851f77 - Time: 23545ms

Warning: C:/Users/THG/My Documents/apps/test33/src/app/app-routing.module.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

Warning: C:/Users/THG/My Documents/apps/test33/src/app/app.component.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

Warning: C:/Users/THG/My Documents/apps/test33/src/app/app.module.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

Warning: C:/Users/THG/My Documents/apps/test33/src/environments/environment.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

Warning: C:/Users/THG/My Documents/apps/test33/src/main.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

Warning: C:/Users/THG/My Documents/apps/test33/src/polyfills.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.



../../../Documents/apps/test33/src/main.ts - Error: Module build failed (from ../../../Documents/apps/test33/node_modules/@ngtools/webpack/src/ivy/index.js):
Error: C:\Users\THG\Documents\apps\test33\src\main.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via
 the 'files' or 'include' property.
    at C:\Users\THG\Documents\apps\test33\node_modules\@ngtools\webpack\src\ivy\loader.js:60:26

../../../Documents/apps/test33/src/polyfills.ts - Error: Module build failed (from ../../../Documents/apps/test33/node_modules/@ngtools/webpack/src/ivy/index.js):
Error: C:\Users\THG\Documents\apps\test33\src\polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at C:\Users\THG\Documents\apps\test33\node_modules\@ngtools\webpack\src\ivy\loader.js:60:26



** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **


× Failed to compile.
- Generating browser application bundles...

Until - Generating browser application bundles... was stuck (looks like hang up)

Anyone having solutions or same problem on it?

What happen with my lappie or nodejs/angular-cli?

It's make me stressing out.


Refer to @brk queestion:

using standard tsConfig files, because it create new from scratch.

tsConfig.json

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2017",
    "module": "es2020",
    "lib": [
      "es2020",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

tsConfig.app.json

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}

tsConfig.spec.json

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/spec",
    "types": [
      "jasmine"
    ]
  },
  "files": [
    "src/test.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.spec.ts",
    "src/**/*.d.ts"
  ]
}

Aargh, I'm not sure with this error.

But, I move the directory projects into other directory outside of parent structure of directory and running well.

Weird.. but useful, the other can trying this solution.

I thought the location C:\Users\ xxx \projects where xxx its become a problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM