首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeScript编译中缺少模块生成失败的% ts。请确保它通过'files‘或'include’属性在您的tsconfig中

TypeScript编译中缺少模块生成失败的% ts。请确保它通过'files‘或'include’属性在您的tsconfig中
EN

Stack Overflow用户
提问于 2018-09-21 23:33:49
回答 4查看 22K关注 0票数 9

我已经将我的应用程序从angular 4升级到angular 6。我得到以下错误。我已经在tsConfig中添加了包含文件。我在运行ng测试时遇到错误。我想知道,当@wtw文件夹包含在tsConfig中时,它为什么会抱怨@wtw文件夹下的文件

代码语言:javascript
复制
"include": [
    "./src/**/*",
    "./node_modules/@wtw/**/*",
     "./node_modules/@types/**/*"
  ]

错误消息

代码语言:javascript
复制
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

代码语言:javascript
复制
{
  "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/**/*"
  ]
}
EN

回答 4

Stack Overflow用户

发布于 2019-01-08 22:43:27

我得到了同样的错误,在您的app.routing.ts文件中,检查惰性模块的路由路径,检查您的组件名称,并准确地更正路径中的小写或大写。

票数 5
EN

Stack Overflow用户

发布于 2018-09-24 22:22:42

只需尝试创建一个angular 6项目并交叉验证您的文件。只需交叉检查以下文件,看看是否有帮助

在tsconfig.json文件中

代码语言:javascript
复制
{
  "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中

代码语言:javascript
复制
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}

在tsconfig.app.json中

代码语言:javascript
复制
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}
票数 2
EN

Stack Overflow用户

发布于 2020-07-13 19:28:34

当文件大小写不匹配时,通常会发生这种情况。举个例子,我有一个名为layout的文件夹,里面有layout-dashboard.ts。在我的导入路径中有以下路径,这导致了一个错误。正确的路径是这个,import { DashboardLayoutComponent } from '../layout/dashboard-layout/dashboard-layout.component';,你需要注意的是,第一个没有给出任何与路径相关的错误。我可以说的是,angular文件夹区分大小写。布局!=布局

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52446988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档