question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v1.5.1 AOT Build - Uncaught ReferenceError: InjectionToken is not defined

See original GitHub issue

Versions

Angular CLI: 1.5.1
Node: 8.6.0
OS: win32 x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

@angular/cli: 1.5.1
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.1
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1

Repro steps

  • ng serve --aot

Observed behavior

Uncaught ReferenceError: InjectionToken is not defined
    at eval (logger.service.ts:20)
    at Object.../../../../../src/app/shared/services/logger/logger.service.ts (main.bundle.js:206)
    at __webpack_require__ (inline.bundle.js:713)
    at fn (inline.bundle.js:118)
    at eval (logger.module.ts:2)
    at Object.../../../../../src/app/shared/services/logger/logger.module.ts (main.bundle.js:198)
    at __webpack_require__ (inline.bundle.js:713)
    at fn (inline.bundle.js:118)
    at eval (index.ts:1)
    at Object.../../../../../src/app/shared/services/index.ts (main.bundle.js:190)

Desired behavior

The app builds fine in AOT mode with no error, but when I run it in the browser, it results in the error provided above during bootstrap process. I tried to reproduce this error on CLI 1.5.0 and it works fine. It complains about InjectionToken being not defined.

Mention any other details that might be useful (optional)

Only happening on v1.5.1, works on v1.5.0. No other dependency was changed. All I did was upgrade @angular/cli from 1.5.0 to 1.5.1.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
hanslcommented, Nov 16, 2017

We’re investigating. If we haven’t found a root cause in 15-30 minutes after this message we’ll revert the PR and do an emergency release.

3reactions
bomberblue07commented, Nov 16, 2017

I have a similar issue. My app worked fine with 5.0.1 and CLI 1.5.0. Once I upgraded to 1.5.1, the app fails to load properly and the first error I get is from one of my components: ReferenceError: EventEmitter is not defined ReferenceError: EventEmitter is not defined

The offending line of code is a declaration of a property of my component before the constructor:

@Output() notify: EventEmitter<string> = new EventEmitter<string>();

Moving this initialization to the constructor didn’t help. My app works fine with a JIT build, but breaks once AOT is involved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AOT compilation error: Uncaught ReferenceError: require is ...
It seems, rollup can't correctly handle non-ordinary imports like import "./polyfills.ts"; and similarly it can handle only imports like ...
Read more >
uncaught referenceerror: process is not defined angular
It complains about InjectionToken being not defined. Mention any other details that might be useful (optional). Only happening on v1.5.1 , works on...
Read more >
InjectionToken - Angular
Use an InjectionToken whenever the type you are injecting is not reified (does not have a runtime representation) such as when injecting an...
Read more >
javascript reference error is not defined Code Example
If you get a javascript reference error, It means that your using a word that //needs to be defined. For example, If I...
Read more >
AngularJS to Angular Quick Reference
AngularJS is the name for all v1.x versions of Angular. ... This guide explains how to build with the AOT compiler and how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found