模块构建失败:错误:TypeScript 编译中缺少 index.ts [英] Module build failed: Error: index.ts is missing from the TypeScript compilation
问题描述
项目描述:我的项目通过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 build"时出错:
Gotting error when doing "npm build":
./node_modules/@myllc/application-core/index.ts 模块中的错误构建失败:错误:TypeScript 编译中缺少/var/www/frontend-skeleton/node_modules/@myllc/application-core/index.ts.请确保它在您的 tsconfig 通过 'files' 或 'include' 属性.丢失的文件似乎是第三方库的一部分.已发布的 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.
解决方案是什么?
推荐答案
解决方案见index.ts 不是编译的一部分.#8284 来自 tapaz1 :
The solution is found in index.ts is not part of the compilation. #8284 by tapaz1 :
2 个 tsconfig.json 文件,一个位于应用程序的根目录,另一个位于 src 文件夹(根目录下一层),名为 tsconfig.app.json,它扩展了主 tsconfig.json.我在包含"数组中明确添加了我需要的没有被 Typescript 转译的包,并且像这里的很多人一样,我得到了 *.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屋!