0

I am getting an error as below on my Angular 5 application. I am using Angular CLI and running from VSCode.

ERROR in : Illegal state: Could not load the summary for directive CdkObserveContent in node_modules/@angular/cdk/observers/typings/index.d.ts.

The error is getting throws only when I execute ng build --prod. The commands ng serve and ng build wors fine.

enter image description here

Any idea, what could be the reason?

Sibeesh Venu
  • 18,755
  • 12
  • 103
  • 140

1 Answers1

1

Ok, let me answer my own question. This is really strange. I have changed the value of rootDir on my tsconfig.json file to ., that solved the issue here. This post really helped me to do so. I am not sure what is the relation ng build --prod has with this rootDir. Now all the commands are working fine.

Previous tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "module": "commonjs",
    "target": "ES5",
    "outDir": "bin",
    "rootDir": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

New tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "module": "commonjs",
    "target": "ES5",
    "outDir": "bin",
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

enter image description here

Hope it helps.

Sibeesh Venu
  • 18,755
  • 12
  • 103
  • 140
  • After run application I got error :ERROR Error: StaticInjectorError(h)[n -> n]: StaticInjectorError(Platform: core)[n -> n]: NullInjectorError: No provider for n! – sameer Mar 04 '19 at 10:45
  • @sameer: run `ng build --prod --optimization=false` and find out what is causing the error – Deepak Thomas May 24 '20 at 07:47