繁体   English   中英

Angular 13.2。 错误:仅将入口点添加到 tsconfig 中的“文件”或“包含”属性

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

我有一个问题,如上所述。

昨天在我的项目上调用 ng serve 时没有显示任何问题。 但是今天它显示了错误。

我正在尝试解决并在 google/stackoverflow 上发现仍然不幸,即使按照建议的每个页面上的解决方案进行操作,例如必须在 tsconfig.app.json 上进行编辑,包括排除部分。

直到全新安装所有 nodejs、npm、angular-cli,包括删除目录安装程序,甚至使用最新的 angular 14.2。 但问题仍然存在。

使用没有任何组件的全新创建新项目进行测试 [使用标准 ng new] (ng new test33) 然后运行 (ng serve) 仍然显示问题。

测试环境版本:

windows:10.0.19044.1766

节点:16.14.0、16.17.1、18.10.0

npm:(来自节点的 package)

角度-cli:13.2.0 - 14.2

但是问题还是出现了。


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... 被卡住了(看起来像挂断了)

有人有解决方案或同样的问题吗?

我的 lappie 或 nodejs/angular-cli 发生了什么?

这让我压力很大。


参考@brk问题:

使用标准的 tsConfig 文件,因为它从头开始创建新的。

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,我不确定这个错误。

但是,我目录项目移动到目录父结构之外的其他目录并且运行良好。

奇怪..但很有用,其他人可以尝试这个解决方案。

我认为位置 C:\Users\ xxx \projects 其中xxx成为问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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