模块构建失败:错误:TypeScript编译中缺少index.ts.

use*_*630 6 angular5

项目描述:我的项目是通过package.json下载到node_module

的package.json

....
   dependencies:{
       ....
       "@myllc/application-core": "git+ssh://git@bitbucket.org/myllc/application-core.git",
       "@myllc/application-shared":"git+ssh://git@bitbucket.org/myllc/application-shared.git",

   }
   ....
Run Code Online (Sandbox Code Playgroud)

在执行"npm build"时出错:

./node_modules/@myllc/application-core/index.ts中的错误.模块构建失败:错误:TypeScript编译中缺少/var/www/frontend-skeleton/node_modules/@myllc/application-core/index.ts.请通过'files'或'include'属性确保它在您的tsconfig中.丢失的文件似乎是第三方库的一部分.已发布库中的TS文件通常是包装严重的库的标志.请在库存储库中打开一个问题,提醒其作者并要求他们使用Angular Package Form(https:// goo.gl/jB3GVv)打包库.

从Angular4升级到Angular5后出现:Tsconfig:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "lib": [
      "es2016",
      "dom"
    ],
    "typeRoots": [
      "node_modules/@types"
    ]

  }

}
Run Code Online (Sandbox Code Playgroud)

我试着补充一下

"include": [
    "./node_modules/@myllc/**/*"
  ]
Run Code Online (Sandbox Code Playgroud)

但在更深的文件夹.ts文件中出现相同的错误.还创建了 https://github.com/angular/angular-cli/issues/8284, 但没有解决这个错误.

解决办法是什么?

use*_*900 3

解决办法是在index.ts中找到不属于编译的部分。#8284Tapaz1提供:

2 个 tsconfig.json 文件,一个位于应用程序的根目录,另一个位于 src 文件夹(根目录下一层)内,名为 tsconfig.app.json,扩展了主 tsconfig.json。我在“include”数组中明确添加了我需要的未由 Typescript 转译的包,并且像这里的很多人一样,我得到了 *.spec.ts 文件,尽管它们位于“排除”选项中,所以我从 tsconfig.json 中删除了它。修复方法是将“排除”选项添加到第二个(扩展)tsconfig.app.json 文件中。

tsconfig.app.json:

{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../dist",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"../node_modules/your_package/**/*.spec.ts"
]
}
Run Code Online (Sandbox Code Playgroud)