Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 899
Zeeshan Malik Avatar asked Aug 21 '19 07:08

Zeeshan Malik


2 Answers

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

like image 128
Chanaka Weerasinghe Avatar answered Sep 23 '22 02:09

Chanaka Weerasinghe


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

like image 21
Rasheek Mohamed Avatar answered Sep 21 '22 02:09

Rasheek Mohamed