Ionic 4 Angular 8 - Uncaught ReferenceError: global is not defined
Asked Answered
A

2

7

M upgrading my ionic app from Ionic 3 to 4. But I got this error.

enter image description here

I know there are many solutions available in other forums. But they didn't work for me.

I tried (window as any).global = window; but it didn't work.

And I also tried to add Dragula. It didn't work either.

What i am missing? What should I do?

Alejandrinaalejandro answered 21/8, 2019 at 7:23 Comment(0)
F
16

as @richardsengers answer

https://github.com/aws-amplify/amplify-js/issues/678#issuecomment-389106098

include this

(window as any).global = window;

In your polyfills.ts file

Favour answered 21/8, 2019 at 7:35 Comment(0)
S
3

If anyone here with the same issue using Ionic 5 with Angular 10,

Install globalthis:

npm install globalthis

Add:

import 'globalthis/auto';

in polyfills.ts

Note : Adding (window as any).global = window; In polyfills.ts file didn't work in my case

Singsong answered 17/2, 2021 at 18:14 Comment(2)
Thank you! life saver. This only happened to me on the android app, the iOS app was okFlagellate
Yeah @C_Ogoo this issue happens only in android.Singsong

© 2022 - 2024 — McMap. All rights reserved.