简体   繁体   English

TypeScript编译中缺少index.ts

[英]index.ts is missing from the TypeScript compilation

I got following error when running 'ng serve'. 运行“ ng serve”时出现以下错误。

node_modules/angular2-indexeddb/index.ts is missing from the TypeScript compilation. TypeScript编译中缺少node_modules / angular2-indexeddb / index.ts。 Please make sure it is in your tsconfig via the 'files' or 'include' property. 请通过“文件”或“包含”属性确保它在您的tsconfig中。 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. 已发布库中的TS文件通常是库包装不良的标志。 Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format ( https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview ). 请在库存储库中打开一个问题,以提醒其作者,并请他们使用Angular打包格式( https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview )打包该库。

I guess the issue is that angular2-indexeddb is not taken into compilation by tsconfig. 我想问题是tsconfig没有将angular2-indexeddb纳入编译。 https://github.com/gilf/angular2-indexeddb https://github.com/gilf/angular2-indexeddb

I think there should be a temporary work around by editting the following configuration in tslint.json, but I need a solution to work through it. 我认为应该通过在tslint.json中编辑以下配置来解决临时问题,但是我需要一种解决方案来解决该问题。

  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ] 

Is it because angular2-indexeddb doesn't provide a good packaged library? 是因为angular2-indexeddb没有提供良好的打包库吗? In fact, I don't think a popular published library should have this issue. 实际上,我认为流行的出版图书馆不应该出现此问题。 Or I missed something for configuration or compilation? 或者我错过了一些用于配置或编译的东西? Can I use package compilation tools/library to compile it into d.ts or spec.ts? 我可以使用软件包编译工具/库将其编译为d.ts或spec.ts吗?

update: 更新:

In fact, I see *.d.ts file in the directory: 实际上,我在目录中看到* .d.ts文件:

ls node_modules/angular2-indexeddb/
LICENSE                                 angular2-indexeddb.metadata.json        index.js
README.md                               angular2-indexeddb.min.js               index.js.map
angular2-indexeddb.d.ts                 angular2-indexeddb.min.js.map           index.ts
angular2-indexeddb.js                   angular2-indexeddb.ts                   package.json
angular2-indexeddb.js.map               index.d.ts

Content in tsconfig.json: 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/angular2-indexeddb/index.ts"
    ]
}

EDIT: I do recommend you change your lib to ngx-indexed-db, so you don't need to do this. 编辑:我确实建议您将您的lib更改为ngx-indexed-db,所以您不需要这样做。

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

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