gpt4 book ai didi

angular5 - 模块构建失败 : Error: index. TypeScript 编译中缺少 ts

转载 作者:行者123 更新时间:2023-12-04 12:57:09 25 4
gpt4 key购买 nike

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

包.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”时出错:

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 后出现:
配置:
{
"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
但没有解决这个错误。

解决办法是什么?

最佳答案

解决方案见 index.ts is not part of the compilation. #8284塔帕兹1 :

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"
]
}

关于angular5 - 模块构建失败 : Error: index. TypeScript 编译中缺少 ts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48561600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com