I have an app that works fine using Ionic Serve. After doing a browser build it gets the following error:
main.js:58805 Uncaught ReferenceError: MyApp is not defined
at Object.a (main.js:58805)
at Object.<anonymous> (main.ts:50)
at __webpack_require__ (bootstrap 994d87c…:19)
at Object.<anonymous> (main.js:65214)
at __webpack_require__ (bootstrap 994d87c…:19)
at Object.<anonymous> (platform-browser.es5.js:4452)
at __webpack_require__ (bootstrap 994d87c…:19)
at Object.<anonymous> (main.js:64904)
at __webpack_require__ (bootstrap 994d87c…:19)
at Object.<anonymous> (main.js:58808)
Looking at those lines in main.js, I find:
"use strict";
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return MyApp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return MyApp; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_ionic_angular__ = __webpack_require__(20);
[...]
[blank lines]
let MyApp = MyApp_1 = class MyApp {
constructor(platform, menu, analytics) {
this.platform = platform;
Aside from the disconcerting duplicate lines, a webpack call is indeed using MyApp before it is defined.
Why is this happening and how do I fix it?
Ionic Info:
global packages:
@ionic/cli-utils : 1.4.0
Cordova CLI : 7.0.1
Ionic CLI : 3.4.0
local packages:
@ionic/app-scripts : 1.3.8
@ionic/cli-plugin-cordova : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms : browser 4.1.0
Ionic Framework : ionic-angular 3.4.2
System:
Node : v7.10.0
OS : Linux 4.4
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
npm : 4.2.0
Thanks