Angular-cli: After "ng build --prod" when trying to load the app it displays error in browser

Created on 23 Feb 2017  Â·  4Comments  Â·  Source: angular/angular-cli

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 7 / 10, Linux (Ubuntu 16.04 LTS)

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
@angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.30]
node: 6.9.5
os: linux x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
When building using "ng build", the build succeeds and app can be accessed.
However, when build in production mode it gives me an error "TypeError: Cannot convert undefined or null to object".

The log given by the failure.

Normally this include a stack trace and some more information.
TypeError: Cannot convert undefined or null to object
at Function.keys ()
at r (vendor.01d0819….bundle.js:1144)
at Object.r [as a] (vendor.01d0819….bundle.js:1144)
at e.get [as _INITIAL_REDUCER_73] (main.517c36c….bundle.js:6)
at e.get [as _Reducer_74] (main.517c36c….bundle.js:6)
at e.get [as _Store_78] (main.517c36c….bundle.js:6)
at e.get [as _LayoutDetailsService_93] (main.517c36c….bundle.js:6)
at e.get [as _UserTokenService_95] (main.517c36c….bundle.js:6)
at e.getInternal (main.517c36c….bundle.js:7)
at e.get (vendor.01d0819….bundle.js:702)
at e.t.injectorGet (vendor.01d0819….bundle.js:43)
at e.createInternal (main.517c36c….bundle.js:6)
at e.t.createHostView (vendor.01d0819….bundle.js:43)
at t.create (vendor.01d0819….bundle.js:29)
at e.bootstrap (vendor.01d0819….bundle.js:483)
screenshot from 2017-02-23 21-13-57

Mention any other details that might be useful.

This issue persists after updating angular-cli to "beta.28" and even on other updates after "beta.28"


Thanks! We'll be in touch soon.

Most helpful comment

When building using "ng build --prod --aot=false" and then serving the application everything works fine!

There seems to be an issue with AOT compilation when doing "ng build --prod"
where by default --aot=true

All 4 comments

When building using "ng build --prod --aot=false" and then serving the application everything works fine!

There seems to be an issue with AOT compilation when doing "ng build --prod"
where by default --aot=true

Without some repro steps there's nothing I can do, sorry.

A good resource for debugging AOT errors is https://github.com/rangle/angular-2-aot-sandbox#aot-dos-and-donts.

This was an issue with the way reducers were declared in the app and when compiled with AOT it was unable to compile those reducers properly.

However, now this issue has been fixed.

Cheers!

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