Cordova GLOBAL is not defined when running on Android

98 Views Asked by At

I have setup a Cordova app with react following this tutorial. When I try to run it on a physical android device using cordova run android -- --livereload The app is not compiled and not sent to the device, the only output I get is:

cordova run android -- --livereload
Successfully built!
GLOBAL is not defined

This is the verbose output of the command:

GLOBAL is not defined
ReferenceError: GLOBAL is not defined
    at Object.isLiveReloadActivated (/Users/ivan/Desktop/MasterThesis/Test2/cordovaReact/plugins/cordova-plugin-livereload/lib/utils/helpers.js:94:5)
    at Object.module.exports.isLiveReloadActive (/Users/ivan/Desktop/MasterThesis/Test2/cordovaReact/plugins/cordova-plugin-livereload/lib/index.js:21:17)
    at module.exports (/Users/ivan/Desktop/MasterThesis/Test2/cordovaReact/plugins/cordova-plugin-livereload/lib/postEmulateRunHook.js:19:13)
    at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:157:32)
    at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:136:12)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:108:40
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

What is GLOBAL and how can I fix this error in order to get my app to compile and live reload?

1

There are 1 best solutions below

1
Eric On

Add this to your index.html file

 <script>const global = globalThis;</script>