Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module build failed ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property

Tags:

angular

I have upgraded my application from angular 4 to angular 6. I am getting the following error. I have already added the include files in the tsConfig. I am getting the error while running ng test. I wonder why it is complaining of a file under @wtw folder when it is included in the tsConfig

"include": [
    "./src/**/*",
    "./node_modules/@wtw/**/*",
     "./node_modules/@types/**/*"
  ]

Error message

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/**/*"
  ]
}
like image 713
Tom Avatar asked Sep 21 '18 15:09

Tom


3 Answers

i got same error,in your app.routing.ts file , check routing path of lazy modules check your component name and correct the lowercase or uppercase in the path, exacactly.

like image 144
elias-heydarpour Avatar answered Oct 24 '22 16:10

elias-heydarpour


This usually happens when file case does not match. For an example, i had a folder called layout with layout-dashboard.ts inside. In my import path had the following path which resulted in an error. import { DashboardLayoutComponent } from '../Layout/dashboard-layout/dashboard-layout.component'; of which the correct path is this one, import { DashboardLayoutComponent } from '../layout/dashboard-layout/dashboard-layout.component'; what you need to notice is that the first doesnt give any path related error. What i can say is the angular folders are case sensitive. layout != Layout

like image 21
Siphamandla Hero Ngwenya Avatar answered Oct 24 '22 17:10

Siphamandla Hero Ngwenya


Just try creating one angular 6 project and cross verify your files. Just cross check below files and see if it helps

In tsconfig.json file

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

In tsconfig.spec.json

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

In tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}
like image 30
Krishna Avatar answered Oct 24 '22 17:10

Krishna