0

NG -V

Angular CLI: 6.2.3
Node: 8.11.3
OS: darwin x64
Angular: 6.1.9
... animations, common, compiler, core, forms, http
... platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.3
@angular-devkit/build-angular     0.8.3
@angular-devkit/build-optimizer   0.8.3
@angular-devkit/build-webpack     0.8.3
@angular-devkit/core              0.8.3
@angular-devkit/schematics        0.8.3
@angular/cdk                      5.2.5
@angular/cli                      6.2.3
@angular/compiler-cli             6.0.3
@angular/fire                     5.0.2
@angular/language-service         5.2.11
@angular/material                 5.2.5
@angular/service-worker           5.2.11
@ngtools/webpack                  6.2.3
@schematics/angular               0.8.3
@schematics/update                0.8.3
rxjs                              6.3.3
typescript                        2.7.2
webpack                           4.20.2

And this is what shows in my console when i run my dist folder with http-server dist/ on localhost:8080 Now the entire application doesn't work because of this error.

Uncaught ReferenceError: global is not defined
  at Object.+SKG (main.c956850f3d270f43f2eb.js:1)
  at f (runtime.ec2944dd8b20ec099bf3.js:1)
  at Object.cD5x (main.c956850f3d270f43f2eb.js:1)
  at f (runtime.ec2944dd8b20ec099bf3.js:1)
  at Object.Vo14 (main.c956850f3d270f43f2eb.js:1)
  at f (runtime.ec2944dd8b20ec099bf3.js:1)
  at Object.gFX4 (main.c956850f3d270f43f2eb.js:1)
  at f (runtime.ec2944dd8b20ec099bf3.js:1)
  at Module.zUnb (main.c956850f3d270f43f2eb.js:1)
  at f (runtime.ec2944dd8b20ec099bf3.js:1)

I tried adding (window as any).global = window; into the polyfills.ts file but it never went off.

Gerald Mathabela
  • 475
  • 2
  • 4
  • 16

1 Answers1

0

You can try two things that may work for you.


Try removing these lines from your polyfills.ts

import 'intl';   
import 'intl/locale-data/jsonp/en.js';

You can see more about this in this thread.


If that doesn't work for some reason, you could update your index.html. Add the following snippet above your closing </head> tag:

<script>    
  var global = global || window;    
  var Buffer = Buffer || [];    
  var process = process || {    
    env: { DEBUG: undefined },  
    version: [] 
  };    
</script>

The first solution should work for you since this was an update made in Angular 6. The second solution I found elsewhere on SO and it helped, but I think the core issue lies in the updates to intl.

I hope this helps.

Dan Kreiger
  • 5,358
  • 2
  • 23
  • 27
  • Well, I don't have the above-mentioned lines on my polyfills.ts file. a – Gerald Mathabela Sep 28 '18 at 13:12
  • this is what i get when i add the script in my index.html file ERROR Error: Uncaught (in promise): Error: StaticInjectorError(o)[t -> t]: StaticInjectorError(Platform: core)[t -> t]: NullInjectorError: No provider for t! Error: StaticInjectorError(o)[t -> t]: StaticInjectorError(Platform: core)[t -> t]: NullInjectorError: No provider for t! – Gerald Mathabela Sep 28 '18 at 13:18