我已将应用程序从4号角升级到6号角。出现以下错误。我已经在tsConfig中添加了包含文件。运行ng test时出现错误。我想知道为什么它包含在tsConfig中时抱怨@wtw文件夹下的文件
"include": [
"./src/**/*",
"./node_modules/@wtw/**/*",
"./node_modules/@types/**/*"
]
错误消息
ERROR in ./node_modules/@wtw/platform/services/index.ts
Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
Error: C:\vstsprojects\testproject\testproject.ClientSide\node_modules\@wtw\platform\services\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 Format .
at AngularCompilerPlugin.getCompiledFile (C:\vstsprojects\testproject\testproject.ClientSide\node_modules\@ngtools\webpack\src\packages\ngtools\webpac
k\src\angular_compiler_plugin.ts:988:15)
at plugin.done.then (C:\vstsprojects\testproject\testproject.ClientSide\node_modules\@ngtools\webpack\src\packages\ngtools\webpack\src\loader.ts:49:29
)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
@ ./src/app/effects/risk-portfolio/risk-portfolio.effect.spec.ts 5:17-50
@ ./src sync \.spec\.ts$
@ ./src/test.ts
tsConfig
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types",
"type-definition"
],
"lib": [
"es2017",
"dom"
]
},
"include": [
"./src/**/*",
"./node_modules/@wtw/**/*",
"./node_modules/@types/**/*"
]
}
答案 0 :(得分:3)
我在您的app.routing.ts文件中遇到了同样的错误,请检查惰性模块的路由路径 检查您的组件名称,并精确地更正路径中的小写字母。
答案 1 :(得分:2)
只需尝试创建一个angular 6项目并交叉验证您的文件即可。只需交叉检查下面的文件,看看是否有帮助
在tsconfig.json文件中
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
在tsconfig.spec.json
中{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
在tsconfig.app.json中
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
答案 2 :(得分:0)
我从Angular 7升级到Angular 8之后又遇到了同样的错误,并且需要升级到update my dist structure。在这种情况下,最简单的方法是只使用ng-packagr。设置非常简单!
答案 3 :(得分:0)
通常在文件大小写不匹配时发生。例如,我有一个名为 layout 的文件夹,其中包含layout-dashboard.ts
。在我的导入路径中,以下路径导致错误。其中正确的路径是import { DashboardLayoutComponent } from '../Layout/dashboard-layout/dashboard-layout.component';
,import { DashboardLayoutComponent } from '../layout/dashboard-layout/dashboard-layout.component';
您需要注意的是,第一个没有给出任何与路径相关的错误。我可以说的是,角度文件夹区分大小写。布局!=布局