Angular-cli: runtime error when application is built with `ng build -prod` (rc.1)

Created on 9 Mar 2017  路  5Comments  路  Source: angular/angular-cli

OS?

Windows 8.1

Versions.

@angular/cli: 1.0.0-rc.1
node: 6.10.0
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 2.4.9

Repro steps.

Whenever I build my application targeting 'Production', compilation is successful (no webpack errors nor warnings) but the targeting 'Development' works without any issues.

I tried the following:

  • ng build works without any issues
  • ng build -aot works without any issues
  • ng build -prod runtime error
  • ng build -prod -aot runtime error

Here's a screenshot (full log output in the following section):
ng build --prod error

The log given by the failure.

Error log from Chrome's Developer console:

vendor.bbd0d03927350012463f.bundle.js:218 EXCEPTION: this.router.events.filter is not a function
t.handleError @ vendor.bbd0d03927350012463f.bundle.js:218
vendor.bbd0d03927350012463f.bundle.js:218 ORIGINAL STACKTRACE:
t.handleError @ vendor.bbd0d03927350012463f.bundle.js:218
vendor.bbd0d03927350012463f.bundle.js:218 TypeError: this.router.events.filter is not a function
    at e.YWx4.e.ngOnInit (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:31244)
    at e.ngDoCheck (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:2011)
    at t.detectChangesInternal (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:3036)
    at t.R2h3.t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:660:5749)
    at t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:57:1302)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5160
    at Array.forEach (native)
    at e.tick (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5127)
    at e._loadComponent (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4723)
    at e.bootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4507)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2555
    at Array.forEach (native)
    at e._moduleDoBootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2526)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:1856
    at t.invoke (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:8982)
t.handleError @ vendor.bbd0d03927350012463f.bundle.js:218
polyfills.049e1c7d689c2e6b80e3.bundle.js:36 TypeError: this.router.events.filter is not a function
    at e.YWx4.e.ngOnInit (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:31244)
    at e.ngDoCheck (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:2011)
    at t.detectChangesInternal (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:3036)
    at t.R2h3.t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:660:5749)
    at t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:57:1302)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5160
    at Array.forEach (native)
    at e.tick (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5127)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:3717
    at t.invoke (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:8982)
    at Object.onInvoke (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:254:2659)
    at t.invoke (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:8922)
    at n.run (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:4717)
    at t.run (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:254:1011)
    at Object.next (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:3700)
o @ polyfills.049e1c7d689c2e6b80e3.bundle.js:36
vendor.bbd0d03927350012463f.bundle.js:218 EXCEPTION: Uncaught (in promise): TypeError: this.router.events.filter is not a function
TypeError: this.router.events.filter is not a function
    at e.YWx4.e.ngOnInit (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:31244)
    at e.ngDoCheck (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:2011)
    at t.detectChangesInternal (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:3036)
    at t.R2h3.t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:660:5749)
    at t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:57:1302)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5160
    at Array.forEach (native)
    at e.tick (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5127)
    at e._loadComponent (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4723)
    at e.bootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4507)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2555
    at Array.forEach (native)
    at e._moduleDoBootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2526)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:1856
    at t.invoke (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:8982)
t.handleError @ vendor.bbd0d03927350012463f.bundle.js:218
vendor.bbd0d03927350012463f.bundle.js:218 ORIGINAL STACKTRACE:
t.handleError @ vendor.bbd0d03927350012463f.bundle.js:218
vendor.bbd0d03927350012463f.bundle.js:218 Error: Uncaught (in promise): TypeError: this.router.events.filter is not a function
TypeError: this.router.events.filter is not a function
    at e.YWx4.e.ngOnInit (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:31244)
    at e.ngDoCheck (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:2011)
    at t.detectChangesInternal (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:3036)
    at t.R2h3.t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:660:5749)
    at t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:57:1302)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5160
    at Array.forEach (native)
    at e.tick (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5127)
    at e._loadComponent (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4723)
    at e.bootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4507)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2555
    at Array.forEach (native)
    at e._moduleDoBootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2526)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:1856
    at t.invoke (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:8982)
    at d (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:2209)
    at f (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:1372)
    at http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:1816
    at t.invokeTask (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:9666)
    at Object.onInvokeTask (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:254:2559)
    at t.invokeTask (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:9587)
    at n.runTask (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:5366)
    at i (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:497)
t.handleError @ vendor.bbd0d03927350012463f.bundle.js:218
polyfills.049e1c7d689c2e6b80e3.bundle.js:36 Unhandled Promise rejection: this.router.events.filter is not a function ; Zone: angular ; Task: Promise.then ; Value: TypeError: this.router.events.filter is not a function
    at e.YWx4.e.ngOnInit (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:31244)
    at e.ngDoCheck (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:2011)
    at t.detectChangesInternal (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:3036)
    at t.R2h3.t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:660:5749)
    at t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:57:1302)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5160
    at Array.forEach (native)
    at e.tick (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5127)
    at e._loadComponent (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4723)
    at e.bootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4507)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2555
    at Array.forEach (native)
    at e._moduleDoBootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2526)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:1856
    at t.invoke (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:8982) TypeError: this.router.events.filter is not a function
    at e.YWx4.e.ngOnInit (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:31244)
    at e.ngDoCheck (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:2011)
    at t.detectChangesInternal (http://localhost:10133/main.67baaca1bd9c3d258a64.bundle.js:1:3036)
    at t.R2h3.t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:660:5749)
    at t.detectChanges (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:57:1302)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5160
    at Array.forEach (native)
    at e.tick (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:5127)
    at e._loadComponent (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4723)
    at e.bootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:4507)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2555
    at Array.forEach (native)
    at e._moduleDoBootstrap (http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:2526)
    at http://localhost:10133/vendor.bbd0d03927350012463f.bundle.js:989:1856
    at t.invoke (http://localhost:10133/polyfills.049e1c7d689c2e6b80e3.bundle.js:36:8982)
o @ polyfills.049e1c7d689c2e6b80e3.bundle.js:36
polyfills.049e1c7d689c2e6b80e3.bundle.js:36 d
o @ polyfills.049e1c7d689c2e6b80e3.bundle.js:36
repro steps

Most helpful comment

@filipesilva finally I figured out what was going on.
I was using this.router.events.filter without importing import 'rxjs/add/operator/filter'

sorry for the misunderstanding

All 5 comments

seeing exactly the same error with version 1.0.0-rc.2

I understand that this is an error you're having in your app but without a simple repro we can't investigate.

@filipesilva finally I figured out what was going on.
I was using this.router.events.filter without importing import 'rxjs/add/operator/filter'

sorry for the misunderstanding

Same Issue

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings