# ReferenceError: globalThis is not defined

**URL:** <https://forum.ionicframework.com/t/referenceerror-globalthis-is-not-defined/201520>\
**Category:** Ionic Framework\
**Created:** [December 19, 2020, 2:31am UTC](https://forum.ionicframework.com/t/referenceerror-globalthis-is-not-defined/201520 "2020-12-19T02:31:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aminem2080](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/aminem2080/32/135307_2.png) [@aminem2080](https://forum.ionicframework.com/u/aminem2080)\
**Post date:** [December 19, 2020, 2:31am UTC](https://forum.ionicframework.com/t/referenceerror-globalthis-is-not-defined/201520/1 "2020-12-19T02:31:32Z")

</div>

Hey guys its been weeks that my app was running great in broswer as serve or serve -l and on some android devices as build -prod and build as apk or run.  
but not running on other devices like android v8.1 it was just the blank white screen

now i found a way to remote debugg it in chrome devtools, this is the error output:

```auto
ReferenceError: globalThis is not defined
    at Module.<anonymous> (vendor-es5.js:158248)
    at Module.spgP (vendor-es5.js:158400)
    at __webpack_require__ (runtime-es5.js:85)
    at Module.ZAI4 (main-es5.js:295)
    at __webpack_require__ (runtime-es5.js:85)
    at Module.zUnb (main-es5.js:647)
    at __webpack_require__ (runtime-es5.js:85)
    at Object._ (main-es5.js:19)
    at __webpack_require__ (runtime-es5.js:85)
    at checkDeferredModules (runtime-es5.js:46)
capacitor.handleError @ capacitor-runtime.js:358
capacitor.handleWindowError @ capacitor-runtime.js:378

```

if i follow in those vendor-es5.js files the error that they is un undefined  
globalThis. on these line of angular fire

`globalThis.ɵAngularfireInstanceCache || (globalThis.ɵAngularfireInstanceCache = new Map());`

help me know what to do in this situation plx  
and thx in advance

---

<div class="post-metadata">

**Author:** ![aminem2080](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/aminem2080/32/135307_2.png) [@aminem2080](https://forum.ionicframework.com/u/aminem2080)\
**Post date:** [December 19, 2020, 11:22am UTC](https://forum.ionicframework.com/t/referenceerror-globalthis-is-not-defined/201520/2 "2020-12-19T11:22:45Z")

</div>

can some one plz help me with this “globalThis. is not defined issue”  
my environment versions are

 ![versions](https://global.discourse-cdn.com/ionicframework/original/3X/2/5/25ea0d27e03134b8d8c78f568e24ebe43c0ab6e3.png)

plz help solve this issue so i can ship my app to the client  
thx

---

<div class="post-metadata">

**Author:** ![ProCom](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@ProCom](https://forum.ionicframework.com/u/ProCom)\
**Post date:** [February 9, 2021, 12:03pm UTC](https://forum.ionicframework.com/t/referenceerror-globalthis-is-not-defined/201520/3 "2021-02-09T12:03:25Z")

</div>

Hello,

Install globalthis:  
`npm install globalthis`

Add:  
`import 'globalthis/auto';`  
in polyfills.ts

---

<div class="post-metadata">

**Author:** ![selestinohajaniaina](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@selestinohajaniaina](https://forum.ionicframework.com/u/selestinohajaniaina)\
**Post date:** [January 9, 2024, 2:52pm UTC](https://forum.ionicframework.com/t/referenceerror-globalthis-is-not-defined/201520/4 "2024-01-09T14:52:39Z")

</div>

hi, where is it? (polyfills.ts)
