You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular5中遇./node_modules/ng4-files/index.ts不在编译输出的错误

Fixing ./node_modules/ng4-files/index.ts is not part of the compilation output Error in Angular 5

我前几天刚上手Angular 5开发,最近碰到了一个棘手的编译错误:

./node_modules/ng4-files/index.ts is not part of the compilation output. Please check the other error messages for details.

这个问题的核心是ng4-files包里的index.ts文件没被纳入Angular的编译流程,我翻遍项目配置也没找到专门编译这个文件的脚本。

经过多次测试验证,我找到了可行的解决方案:把node_modules/ng4-files/index.ts路径添加到项目根目录tsconfig.json的"include"区块中,让Angular编译器明确将这个文件纳入编译范围。

修改后的tsconfig.json示例如下:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "include": [
    "src/**/*",
    "node_modules/ng4-files/index.ts"
  ]
}

亲测这个方法能完美解决问题,希望能帮到遇到同样困扰的小伙伴!

内容的提问来源于stack exchange,提问作者Anil Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:31:48