So I updated to the latest Ionic 3 release and now I’m getting an issue on a production build.
Is there anyway I can get more information on this error that’s being thrown?
I’ve spent a day and reduced my code down to pretty much nothing but I’m still getting the below error. It all works fine with ionic serve.
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at 0.js:1
at 0.js:1
at e.exports (0.js:1)
at 0.js:1
at Array.forEach (<anonymous>)
at Object.<anonymous> (0.js:1)
at e (vendor.js:1)
at Object.<anonymous> (0.js:1)
at e (vendor.js:1)
at Object.<anonymous> (0.js:1)
at 0.js:1
at 0.js:1
at e.exports (0.js:1)
Sometimes things are changed. Basically you’re calling ‘.length()’ on something that more than likely doesn’t exist.
This can happen because things are changed and sometimes methods are moved. For example in a recent patch I had to perform the following update to my code:
The _native property was no longer needed, so the portions of code referencing it were throwing undefined errors. It is potentially working in ionic serve because the web browser is still comfortable with accessing that property that way.
Ionic serve does not run ngc. Building with --prod does. You’re probably getting an error from the Angular compiler, which is more strict than what Ionic serve uses.
Well - Upgrading to ‘ionic-angular 3.9.0’, added type definitions for Chart.js too: npm install @types/chart.js --save-dev
The upgrade seems to fix the prod build problem I was having. Adding the type definitions for Chart.js solves my IDE problem of “cannot resolve symbol” at import.