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:
- Created 5 years ago
- Reactions:7
- Comments:27 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I had the same issue concerning the
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';adding this line in to pollyfills.ts fixed my problem (just a workaround as @Gerros said)
(window as any).global = window;