Cordova GLOBAL 在 Android 上运行时未定义。

huangapple go评论48阅读模式
英文:

Cordova GLOBAL is not defined when running on Android

问题

我已经按照这个教程创建了一个使用React的Cordova应用程序。当我尝试在物理安卓设备上运行它时,使用 cordova run android -- --livereload 命令时,应用程序未编译并未发送到设备,我唯一得到的输出是:

cordova run android -- --livereload
成功构建!
GLOBAL 未定义

这是该命令的详细输出:

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

GLOBAL 是什么,我如何修复这个错误以便编译和实时重新加载我的应用程序?

英文:

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

得分: 1

将以下内容添加到您的index.html文件中:

<script>const global = globalThis;</script>
英文:

Add this to your index.html file

 &lt;script&gt;const global = globalThis;&lt;/script&gt;

huangapple
  • 本文由 发表于 2023年2月9日 02:12:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390065.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定