When run ionic in prod mode : Uncaught (in promise): ReferenceError: _this is not defined ReferenceError: _this is not defined


#1

When I run Ionic normally I got the app work however when I run it in the production mode I got the below error :
ERROR Error: Uncaught (in promise): ReferenceError: _this is not defined
ReferenceError: _this is not defined.

My Ionic env :
cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 7.1.0 

local packages:

@ionic/app-scripts : 3.1.9
Cordova Platforms  : browser 5.0.3
Ionic Framework    : ionic-angular 3.9.2

System:

ios-deploy : 1.9.1 
ios-sim    : 5.0.13 
Node       : v8.9.4
npm        : 5.6.0 
OS         : macOS High Sierra
Xcode      : Xcode 9.1 Build version 9B55 

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

#2

Do you mean:

ionic serve

Do you mean?

npm run build --prod
npm install http-server -g
http-server ./www

Then navigate to:


http://localhost:8100

#3

Yes , running ionic serve works fine or anything except running with --prod on any platform ! give white screen , when for example I run
ionic cordova run browser --prod
It gives me white screen when I opened the console I got the below :
Uncaught (in promise): ReferenceError: _this is not defined ReferenceError: _this is not defined


#4

The Ionic CLI doesn’t support the ‘browser’ platform.

See:


#5

Hi ,
I was able to solve the issue , and it is not related to the error above ( Uncaught in promise … ) I had to track the bug by removing module by module and then found the bug that is related to database sqlite3 … anyway what I am saying there is no easy way to detect the error if it is shown on ionic --prod since the code it self is uglified and compressed , so my advice is each time we add new feature is to try to run prod mode just for testing .