question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular 6: Uncaught ReferenceError: global is not defined

See original GitHub issue
[x] bug report

Current behavior After upgrading to angular 6 and making a production build my application does not work anymore and in the console of the browser following error appears: Uncaught ReferenceError: global is not defined

Expected behavior Application works without errors

Reproduction of the problem I am using version 4.0.1 of swimline ngx-dnd and angular 6.0.2, it works with ng serve, but not with a production build Create a new Angular Project with the Angular cli (6.0.3), ng new mytest, add the swimlane dnd library (4.0.1) and use e.g. the ngx-dnd-container component in the template, make a prod build and open the app

This is a known issue after upgrading to angular 6: https://github.com/angular/angular-cli/issues/9827#issuecomment-369578814

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:27 (7 by maintainers)

github_iconTop GitHub Comments

50reactions
tobias74commented, May 29, 2018

I had the same issue concerning the

import ‘intl’;

in polyfills. The solution proposed in https://github.com/angular/angular-cli/issues/8160#issuecomment-386153833 did not fully resolve my situation.

For me the problem was that all the imports in polyfill.ts were hoisted and executed before I could initialize

(window as any).global = window;

Solution:

I put the above line

(window as any).global = window;

in a new empty file called “global-shim.ts” and imported it at the very top of polyfill.ts:

import 'global-shim';

14reactions
kemalbirincicommented, Jun 21, 2018

adding this line in to pollyfills.ts fixed my problem (just a workaround as @Gerros said)

(window as any).global = window;

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading to angular-6.x gives "Uncaught ReferenceError
Then you're getting the following error Fix: "Uncaught ReferenceError: global is not defined" do it as follows node: { global: true, ...
Read more >
Uncaught ReferenceError: global is not defined #2141 - GitHub
If indeed you are using Angular 6 as I am. 6
Read more >
How to fix the ReferenceError: global is not defined error in ...
I spent hours trying to figure this out and it was really difficult to find the exact information on the web since this...
Read more >
global is not defined aws-sdk - You.com | The AI Search ...
I'm testing an Angular 6 app with AWS Cognito and noticed an error in my console. "Uncaught ReferenceError: global is not defined".
Read more >
“index.js:43 Uncaught ReferenceError: global is not define ...
ReferenceError : global is not defined ; 1. <script> ; 2. var global = global || window; ; 3. var Buffer = Buffer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found