1

version

Angular CLI: 12.0.2
Node: 14.17.0
Package Manager: npm 6.14.13
OS: win32 x64

Angular: 12.0.2
... cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.2
@angular-devkit/build-angular   12.0.2
@angular-devkit/core            12.1.2
@angular-devkit/schematics      12.0.2
@schematics/angular             12.0.2
rxjs                            6.6.6
typescript                      4.2.4

on ng serve, the following happens

runtime.js:1 Uncaught ReferenceError: global is not defined
    at runtime.js:1
    at runtime.js:1
    at runtime.js:1
(anonymous) @ runtime.js:1
(anonymous) @ runtime.js:1
(anonymous) @ runtime.js:1
polyfills.js:1 Uncaught ReferenceError: global is not defined
    at polyfills.js:1
(anonymous) @ polyfills.js:1
styles.js:1 Uncaught ReferenceError: global is not defined
    at styles.js:1
(anonymous) @ styles.js:1
main.js:1 Uncaught ReferenceError: global is not defined
    at main.js:1

Here's how I've tried

  1. polyfills.ts
(window as any).global = window;
  1. add new file and put the line (global-shim.ts)
(window as any).global = window;

polyfills.ts

import 'global-shim';

not all work. how can i solve it?

  • did u try adding in the index.html file? https://stackoverflow.com/questions/50356408/upgrading-to-angular-6-x-gives-uncaught-referenceerror-global-is-not-defined – laiju Jul 22 '21 at 02:05

0 Answers0