Meena Mana
Meena Mana

Reputation: 249

index.ts is not part of the compilation output

I am trying to compile my Angular application and am getting an error. It seems to be with the compiler not recognizing the index.ts file. I'm not sure why.

Below is the error:

ERROR in ./node_modules/datatable/index.ts
Module build failed: Error: node_modules\datatable\index.ts is not part of the compilation output. Please check the other error messages for details.
    at AngularCompilerPlugin.getCompiledFile (node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
    at plugin.done.then (node_modules\@ngtools\webpack\src\loader.js:467:39)
    at process._tickCallback (internal/process/next_tick.js:103:7)
 @ ./src/main/ui/app/app.module.ts 13:0-59
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
ERROR in ./node_modules/typeahead/index.ts
Module build failed: Error: node_modules\typeahead\index.ts is not part of the compilation output. Please check the other error messages for details.
    at AngularCompilerPlugin.getCompiledFile (\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
    at plugin.done.then (node_modules\@ngtools\webpack\src\loader.js:467:39)
    at process._tickCallback (internal/process/next_tick.js:103:7)
 @ ./src/main/ui/app/app.module.ts 12:0-59
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Does anyone have any suggestions on how to fix this? Thank you.

Upvotes: 7

Views: 7992

Answers (5)

Jeroen Cordfunke
Jeroen Cordfunke

Reputation: 1

I got this message too, and for me the cause was a simple typo. I had this line:

import { DashboardService } from '../Dashboard.service';

The capital D was the cause, changing it into lowercase solved the issue.

Upvotes: 0

Miroslav Jonas
Miroslav Jonas

Reputation: 6627

Just to clarify why this is happening in the first place. If published module has typescript files, compiler will try to load those instead of intended compiled javascript files.

This is obviously a mistake in the publish process, as the only ts files should be definition ones (*.d.ts).

If these (typeahead and datatable) are your packages, please check your .npmignore file. Every .ts file except for .d.ts should be ignored. If they're not yours, please be so kind to report this to the creator/owner.

Upvotes: 1

slfan
slfan

Reputation: 9129

I had a similar issue when the application directory was somewhere under the %users%\Documents directory. After I copied the whole directory into another path (e.g. C:\Data\Angular), the error was gone.

Upvotes: 0

B.Altair
B.Altair

Reputation: 76

I had a similar issue with angular-bootstrap-md\index.ts

how I could fix it:

Just put the index.ts file to the tsconfig.jsons include block , see below:

{
  "compileOnSave": false,
  "compilerOptions": {
  "outDir": "./dist/out-tsc",
  "sourceMap": true,
  "declaration": false,
  "moduleResolution": "node",
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "target": "es5",
  "typeRoots": [
    "node_modules/@types"
  ],
  "lib": [
    "es2017",
    "dom"
  ]  
},
"include": [
  "src/**/*",
  "node_modules/angular-bootstrap-md/index.ts"
  ]
 }

Source: https://github.com/angular/angular/issues/20091

Upvotes: 5

Meena Mana
Meena Mana

Reputation: 249

This was the simple fix- Run the following: npm install --save @ngtools/[email protected]

Upvotes: 1

Related Questions