Angular 5 webpack编译错误

Tom*_*omP 7 angular-cli angular angular5

升级到Angular 5和Cli 1.5后,ng serve我收到一个错误:

ERROR in ./node_modules/@stomp/ng2-stompjs/index.ts
    Module build failed: Error: ...\project\node_modules\@stomp\ng2-stompjs\index.ts is not part of the compilation output. Please check the other error messages for details.
        at AngularCompilerPlugin.getCompiledFile (...\project\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
        at plugin.done.then (...\project\node_modules\@ngtools\webpack\src\loader.js:467:39)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)
     @ ./src/app/app.module.ts 27:0-63
     @ ./src/main.ts
     @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
Run Code Online (Sandbox Code Playgroud)

我试图添加include到我的tsconfig.app.json所以它看起来像这样:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "baseUrl": "",
    "types": []
  },
  "include": [
    "../node_modules/@stomp/**/*.ts"
  ],
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我试过重新运行ng serve我又得到了一个错误:

    ERROR in ./src/main.ts
Module build failed: Error: ...project\chatAngular4\src\main.ts is not part of the compilation output. Please check the other error messages for details.
    at AngularCompilerPlugin.getCompiledFile (...project\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
    at plugin.done.then (...project\node_modules\@ngtools\webpack\src\loader.js:467:39)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
ERROR in ./src/polyfills.ts
Module build failed: Error: C:\Users\MEP2\Desktop\chatAngular4\src\polyfills.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (...project\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
    at plugin.done.then (...project\node_modules\@ngtools\webpack\src\loader.js:467:39)
    at <anonymous>
 @ multi ./src/polyfills.ts
Run Code Online (Sandbox Code Playgroud)

这看起来需要某种通用的解决方法.有任何想法吗?


更新

将所有软件包更新到最新版本后,问题就消失了

aar*_*ron 1

关于 main.ts 和 polyfills.ts 未包含在配置中,我遇到了与您相同的错误。

我将这些文件添加到 tsconfig.app.json 文件的“include”部分,它开始为我工作。

奇怪的是,在我将其添加到我的第一个项目中后,我创建了另一个项目并且不需要采取额外的步骤。

这是我的 tsconfig.app.json:

   {
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ],
  "include": [
    "main.ts",
    "polyfills.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)