Peter C. Glade
Peter C. Glade

Reputation: 629

ERROR in : Error: Internal error: unknown identifier {}

im working on an angular app. Everything's works fine while developing, but when I want to build the productive version using:

ng build --prod --aot

i got the following error:

> ng build --prod --aot

Browserslist: caniuse-lite is outdated. Please run next command `npm update`

Date: 2019-12-12T16:15:13.967Z
Hash: 3d59c47f3fb49f8e51cf
Time: 28553ms
chunk {0} runtime.741402d1d47331ce975c.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.4af9b61479361f268d39.js (main) 128 bytes [initial] [rendered]
chunk {2} polyfills.d64fff5b0a45205ed7b5.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} polyfills-es5.cae7692ec3ddfa1785ab.js (polyfills-es5) 68.1 kB [initial] [rendered]
chunk {4} styles.b944be682ec3583295e3.css (styles) 351 kB [initial] [rendered]

ERROR in : Error: Internal error: unknown identifier {}
    at Object.importExpr$1 [as importExpr] (/Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:25070:27)
    at tokenExpr (/Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:21548:43)
    at depDef (/Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:21554:76)
    at /Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:21544:68
    at Array.map (<anonymous>)
    at singleProviderDef (/Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:21544:40)
    at providerDef (/Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:21470:13)
    at /Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:21644:81
    at Array.map (<anonymous>)
    at NgModuleCompiler.compile (/Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:21644:48)
    at AotCompiler._compileModule (/Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:25015:36)
    at /Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:24934:70
    at Array.forEach (<anonymous>)
    at AotCompiler._compileImplFile (/Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:24934:23)
    at /Users/ilem0n/Projekte/Private/NGBudgetManager/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:24924:74
    at Array.map (<anonymous>)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:prod: `ng build --prod --aot`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ilem0n/.npm/_logs/2019-12-12T16_15_14_106Z-debug.log

Process finished with exit code 1

My Config:

Angular CLI: 8.3.20
Node: 12.10.0
OS: darwin x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.20
@angular-devkit/build-angular     0.803.20
@angular-devkit/build-optimizer   0.803.20
@angular-devkit/build-webpack     0.803.20
@angular-devkit/core              8.3.20
@angular-devkit/schematics        8.3.20
@angular/cdk                      8.2.3
@angular/cli                      8.3.20
@angular/flex-layout              8.0.0-beta.27
@angular/http                     8.0.0-beta.10
@angular/material                 8.2.3
@ngtools/webpack                  8.3.20
@schematics/angular               8.3.20
@schematics/update                0.803.20
rxjs                              6.5.3
typescript                        3.5.3
webpack                           4.39.2

I've found some alike problems online but none of them helped me. What I found online

Angular Compiler throws Internal error: unknown identifier {}

ERROR in : Error: Internal error: unknown identifier []" when running ng build --prod

I have no super class injectable and the OpaqueToken is not used or imported in my project.

Any ideas how to figure this out ?

Upvotes: 3

Views: 2986

Answers (3)

Mustafa Omran
Mustafa Omran

Reputation: 344

remove the window object from the providers list at component

@Component({
  selector: 'app-hello',
  templateUrl: './hello.component.html',
  styleUrls: ['./hello.component.scss'],
  // providers: [
  //   { provide: Window, useValue: window }
  // ]
})

Upvotes: 0

naib khan
naib khan

Reputation: 1128

If you are using Window as provider just remove it

  { provide: Window, useValue: window},

Upvotes: 2

Peter C. Glade
Peter C. Glade

Reputation: 629

Figured it out: In my shared module which is imported in every feature I had the following line:

providers: [
  { provide: MAT_DIALOG_DATA, useExisting: {} }
]

after i have removed these the build is running wonderfully.

Upvotes: 3

Related Questions