模块构建失败:错误:TypeScript编译中缺少index.ts [英] Module build failed: Error: index.ts is missing from the TypeScript compilation

查看:1058
本文介绍了模块构建失败:错误:TypeScript编译中缺少index.ts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

项目说明:我的项目正在通过package.json下载到node_module

Description of the project: My project is downloading to node_module via package.json

Package.json

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",

   }
   ....

执行"npm构建"时出现错误:

Gotting error when doing "npm build":

./node_modules/@myllc/application-core/index.ts模块中的

ERROR 构建失败:错误: TypeScript编译中缺少/var/www/frontend-skeleton/node_modules/@myllc/application-core/index.ts.请确保它在 您的tsconfig通过文件"或包含"属性.丢失的文件 似乎是第三方图书馆的一部分. TS文件已发布 库通常是库包装不良的标志.请打开 库存储库中的问题,以警告其作者并请他们 使用Angular Package Form将库打包 (https:// goo.gl/jB3GVv).

ERROR in ./node_modules/@myllc/application-core/index.ts Module build failed: Error: /var/www/frontend-skeleton/node_modules/@myllc/application-core/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Form at (https:// goo.gl/jB3GVv).

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

This appear after upgrade from Angular4 to 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"
    ]

  }

}

我尝试添加

"include": [
    "./node_modules/@myllc/**/*"
  ]

,但是在更深的.ts文件夹中出现相同的错误.也成立 https://github.com/angular/angular-cli/issues/8284 但没有任何方法可以解决此错误.

but there appear same error at deeper folder .ts file. Also founding https://github.com/angular/angular-cli/issues/8284 but nothing solved this error.

解决方案是什么?

推荐答案

该解决方案位于

2个tsconfig.json文件,一个位于应用程序的根目录,另一个位于src文件夹(位于根目录下一级)内,名为tsconfig.app.json,该文件扩展了主要的tsconfig.json.我在"include"数组中明确添加了Typescript无法转译的我需要的软件包,就像这里的很多人一样,尽管我将它们包含在".exclude"选项中,但我还是获得了* .spec.ts文件,所以我从tsconfig.json中删除了它.该修复程序是在第二个(扩展的)tsconfig.app.json文件中添加了排除"选项.

2 tsconfig.json files, one at the root of the app, and the other inside the src folder (one level down from the root) named tsconfig.app.json that extends the main tsconfig.json. I explicitly added the package that I needed that wasn't being transpiled by Typescript in the "include" array, and like a lot of people here I was getting the *.spec.ts files included despite having them in "exclude" option, so I removed it from the tsconfig.json. The fix was adding the "exclude" option to the second (extended) tsconfig.app.json file.

tsconfig.app.json:

{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../dist",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"../node_modules/your_package/**/*.spec.ts"
]
}

这篇关于模块构建失败:错误:TypeScript编译中缺少index.ts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆