Angular AOT Build: Internal error: unknown identifier undefined

error in error: internal error: unknown identifier undefined at object.importexpr$1 [as importexpr]
angular error in : error: internal error: unknown identifier []
internal error: unknown identifier angular
error in error: internal error: unknown identifier angular
error: internal error: unknown identifier angular
error in error: internal error: unknown identifier [] at object.importexpr$1 [as importexpr]
node_modules/@angular/compiler/bundles/compiler umd js
ionic error in error internal error unknown identifier

My current Angular 2 project started before Angular supported the AOT feature. Now, I’m trying to get it to work. I'm receiving the following error and I've no clue what this means and where I can start to debug the issue:

ERROR in Error: Internal error: unknown identifier undefined
at Object.importExpr$$1 [as importExpr] (...\node_modules\@angular\compiler\bundles\compiler.umd.js:24211:23)
at tokenExpr (...\node_modules\@angular\compiler\bundles\compiler.umd.js:18577:39)
at providerDef (...\node_modules\@angular\compiler\bundles\compiler.umd.js:18480:20)
at ...\node_modules\@angular\compiler\bundles\compiler.umd.js:18697:77
at Array.map (<anonymous>)
at NgModuleCompiler.compile (...\node_modules\@angular\compiler\bundles\compiler.umd.js:18697:44)
at AotCompiler._compileModule (...\node_modules\@angular\compiler\bundles\compiler.umd.js:24144:32)
at ...\node_modules\@angular\compiler\bundles\compiler.umd.js:24056:66
at Array.forEach (<anonymous>)
at AotCompiler._compileImplFile (...\node_modules\@angular\compiler\bundles\compiler.umd.js:24056:19)
at ...\node_modules\@angular\compiler\bundles\compiler.umd.js:23969:87
at Array.map (<anonymous>)
at AotCompiler.emitAllImpls (...\node_modules\@angular\compiler\bundles\compiler.umd.js:23969:52)
at CodeGenerator.emit (...\node_modules\@angular\compiler-cli\src\codegen.js:42:46)
at ...\node_modules\@angular\compiler-cli\src\codegen.js:33:61
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

Dependencies

"@angular/animations": "^4.4.4",
"@angular/common": "^4.4.4",
"@angular/compiler": "^4.4.4",
"@angular/core": "^4.4.4",
"@angular/forms": "^4.4.4",
"@angular/platform-browser": "^4.4.4",
"@angular/platform-browser-dynamic": "^4.4.4",
"@angular/router": "^4.4.4",
"@ngx-translate/core": "^8.0.0",
"@ngx-translate/http-loader": "^2.0.0",
"core-js": "^2.5.1",
"font-awesome": "^4.7.0",
"primeng": "^4.2.1",
"quill": "^1.3.2",
"rxjs": "^5.4.3",
"zone.js": "^0.8.18"

Has anyone an idea why this error occurs?


This part of the application caused the problem:

export function windowFactory(): any {
    return window;
}

providers: [{
    provide: Window,
    useFactory: windowFactory
}],

Github: This fails with AoT compiler in Angular CLI, because Window (the browser window) is an interface

"ERROR in : Error: Internal error: unknown identifier , The problem is cause by AOT. when running prod without aot it will compile Brocco added the comp: devkit/build-angular label on Jun 25, 2018 ERROR in : Error: Internal error: unknown identifier undefined #31658. ERROR in : Error: Internal error: unknown identifier undefined #31658. earshinov opened this issue Jul 13, 2018 · 4 comments. There are already similar bug reports, for example angular/angular-cli#11359, but such errors seem complicated and difficult to solve enough to justify individual tracking of each problem.


I faced the same error in my Angular 6 project.

when you run "ng build --prod", read the warning messages carefully. In which file it throws warning message (for eg:dataservice.ts).

then go to that (dataService.ts) file and remove the @Injectable.

@Injectable({
providedIn: 'root'
})

Then try to build again. It works for me.

AOT Compile Error "Internal error: unknown identifier undefined , AOT Compile Error "Internal error: unknown identifier undefined" #10086 project https://github.com/CarstenLeue/angular-build-problem.git  Angular cli build error: Error: Internal error: unknown identifier undefined at Object.importExpr$$1 #2033 Closed ScottyTarvan opened this issue Mar 3, 2018 · 6 comments


Just for completeness since I stumbled upon the same error in a different context. The error occurred in my build when using an upgraded angularjs service class that was exported as default

// Service definition
export default class MyService { /* Registered AngularJS service here */ }

// Module
import MyService from './my-service'

// Upgrade 
export function myServiceFactory(i:any) {
  return i.get('myService');
}

// ngUpgraded Angular main module 
@NgModule({
  providers: [
    { provide: MyService, useFactory: myServiceFactory, deps: ['$injector'] }
  ]
})

Removing the default export resolved the issue.

AOT Error: Internal error: unknown identifier undefined, Internal error: unknown identifier undefined at Object.importExpr$$1 [as importExpr] (\node_modules\#angular\compiler\bundles\compiler.umd.js:24211​:23)  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.


Had the same error when trying to provide Date for injection instead of an injection token.

So I did:

providers: [
    { provide: Date, useValue: new Date() }
  ]

and changed it to

providers: [
    { provide: NOW, useValue: new Date() },
  ],

where NOW is defined in the service that depends on it like this

export const NOW = new InjectionToken<Date>('now');

All documented on the Angular site.

Angular AOT Build: Internal error: unknown identifier undefined, AOT Error: Internal error: unknown identifier undefined importExpr$$1 [as importExpr] (/Users/ehorodys/Projects/Ionic2/flagship/node_modules/@angular/ Build in --prod mode with AOT turned off (worse case scenario)  Angular AOT Build: Internal error: unknown identifier undefined This happened to my due to Class Inheritance, where both the BaseClass and the DriveClass had @Injectable decorator. @Injectable({ providedIn: 'root' }) export class BaseService {


For me, I created a base class for my services that uses HttpClient.

The base class and the sub class were marked as Injectable.

I removed Injectable from the base class and it solved the issue.

ERROR in : Error: Internal error: unknown identifier [], angular error in : error: internal error: unknown identifier [] error in error: internal error: unknown identifier undefined at object.importexpr$1 [as importexpr] I experienced this issue after upgrading from Angular 7 to 8. I had a service which constructor had arguments that were not @Injectable(), and thus had to make them so.I changed my service to this:


Cryptic error in build for production although regular build succeeds , ng build --prod or ng build --aot. The problem is cause by AOT. when running prod without aot it will compile successfully. The log given by the failure. ERROR in : Error: Internal error: unknown identifier [] at Object. Desktop\dev\Tapp\tapp-​client\tapp\node_modules@angular\compiler\bundles\compiler.umd.js:20493:23) at  The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code. Compiling your application during the build process provides a faster rendering in the browser.


Angular AOT unknown identifier undefined - angular, The problem is cause by AOT. when running prod without aot it will compile successfully. @angular-devkit/architect 0.6.3 @angular-devkit/build-angular 0.6.3 ERROR in : Error: Internal error: unknown identifier undefined at Object. Angular makes use of " @Optional () @Host () parent: ControlContainer" to get the form. myCustomInjector within the dynamic component makes use of the injector of the form component as parent, so it is able to return a ControlContainer. But the @Host thing seems to prevent from using it.


I am currently puzzled in one of my Angular 7 projects that the build for production ("ng ERROR in : Error: Internal error: unknown identifier [] at AotCompiler. ERROR in : Error: Internal error: unknown identifier undefined at Object.importExpr$$1 [as importExpr] (C:\Users\Mikalai\Desktop\warehouses.by\front ode_modules\@angular\compiler\bundles\compiler.umd.js:20493:23)