--prod is giving error "c not defined on man.js (line:1) vendor.js(line:1)"

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.13.1
ionic (Ionic CLI) : 3.13.1

global packages:

cordova (Cordova CLI) : 7.1.0 

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : browser 5.0.0
Ionic Framework    : ionic-angular 3.7.1

System:

Node  : v6.11.2
npm   : 3.10.10 
OS    : macOS Sierra
Xcode : Xcode 8.3.2 Build version 8E2002 

Misc:

backend : legacy

What command are you executing?
Does it work without --prod?

Without Prod it works perfectly fine.
It works with ionic serve, ionic cordova run android, ionic cordova run ios
but when i add --prod it give me the following error

Uncaught TypeError: Cannot read property ‘c’ of undefined
at Object.81 (main.js:1)
at e (vendor.js:1)
at Object.435 (main.js:1)
at e (vendor.js:1)
at window.webpackJsonp (vendor.js:1)
at main.js:1

See where it tries to read a “c” property of an object, try to understand what of your code that aligns to. Doing anything special/fancy there?

As per my debuging, It looks like window.webpackJsonp is giving an error.

I am migrating my project from old angular 4.1.3 to 4.4.3 and from old app script 1.3.* to 3.0.0.

It says so right in the error message :wink:

But in general the versions you are migrating too are fine, they are part of the base project thousands of devs are using: https://github.com/ionic-team/ionic2-app-base/blob/master/package.json

So it probably is some bit in your code that after compiling and optimizing (which is what --prod does) ends up broken.

No errors are displayed, and the first page is also not loaded, the error recevied is prior to app load
at Object.81 (main.js:1)
at e (vendor.js:1)
at Object.435 (main.js:1)
at e (vendor.js:1)
at window.webpackJsonp (vendor.js:1)
at main.js:1

this is the only error i get

@Sujan12

  1. I started with a new blank project.
  2. Reinstalled all the packages which were required for my project.
  3. Added required scripts in index.html
  4. moved all required folder to to blank app.
  5. ionic serve: app works fine.
  6. ionic cordova run android : works fine.
  7. ionic cordova run browser --prod. ERROR

Error: Uncaught TypeError: Cannot read property ‘c’ of undefined
at Object.80 (main.js:1)
u = Object(d.__decorate)([Object(c.Injectable)(), Object(d.__metadata)("design:paramtypes", ["function" == typeof (p = void 0 !== g.a && g.a) && p || Object, "function" == typeof (m = void 0 !== S.c && S.c) && m || Object])], u);

at e (vendor.js:1)
return t[n].call(i.exports, i, i.exports, e),

at Object.433 (main.js:1)

b = a(80 )
at e (vendor.js:1)
at window.webpackJsonp (vendor.js:1)
u = e(e.s = s[l]);

at main.js:1
webpackJsonp([58]

See at each step you just did where it starts breaking with --prod. Then divide that step into smaller steps and see again.

as per 3.0.0 change log.

I am getting an error with --aot flag.

I was able to then further debug into the code. !!FIXED

But this was not possible with --prod falg.

Thanks @Sujan12

Awesome. Can you tell a bit more what exactly was the problem?

I think you should give us an explanation what was wrong in --prod mode. I have the similar problem, it started to appear about 3-4 days ago

I think there some troubles with js uglify. After processing output js is broken

when we do ionic serve or build without prod flag, it ignores certain errors or unmet dependencies, but when we build with --prod flag, it throws an error, because the files are not minified and compressed it throws an error on the first line of main.js.

I further debug my code using --aot flag and found that I had written some js wrongly in app.component.ts which was not captured initially while performing ionic serve.

It has been a while i will update once i recollect the exact error