aws-mobile-appsync-sdk-js
aws-mobile-appsync-sdk-js copied to clipboard
ReferenceError: global is not defined
Note: If your issue/feature-request/question is regarding the AWS AppSync service, please log it in the official AWS AppSync forum
Do you want to request a feature or report a bug? bug
What is the current behavior? ReferenceError: global is not defined in javascript
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
> ng new bug
> cd bug
> yarn add aws-appsync
# import anything from aws-appsync, eg.
> cat > src/app/app.component.ts
import { Component } from '@angular/core';
import { AWSAppSyncClient } from 'aws-appsync';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'bug';
constructor() {
AWSAppSyncClient;
}
}
# ctrl+d
> ng serve
# ReferenceError: global is not defined
# showed up in firefox console
What is the expected behavior? Successfully imported and can be used in browser.
Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?
- firefox 68.0b8 (64-bit)
- chromium Version 75.0.3770.80 (Official Build) Arch Linux (64-bit)
- Linux cti 5.1.7-arch1-1-ARCH #1 SMP PREEMPT Tue Jun 4 15:47:45 UTC 2019 x86_64 GNU/Linux
- @angular/cli 8.0.3
- not sure if it affects previous version
+1 I'm also experiencing this issue. @pickfire did you find any solution?
Update: I've found a quick workaround that works for me.
Add
(window as any).global = window;
to your polyfills.ts
.
Ref: https://github.com/angular/angular-cli/issues/9827#issuecomment-386154063
I think I probably did that.
It's been three years now, why hasn't it been fixed yet?