-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught ReferenceError: global is not defined in latest Angular 6 RC #678
Comments
@richardsengers thank you for reporting this! We are following the topic and will see what we can do in the mean time. |
Not sure what the status of this is, since it is marked as closed but the latest version does not have a fix. #139 is referenced above, but 139 has a reference back to this issue. Please clarify? |
Hi @glitchbane |
Just for reference, I have passed through this issue with adding these lines on my index.html head:
|
@CihanSari The workaround you provided works 👍 |
I think for now the best option would be to include
In your polyfills.ts file, as mentioned here: |
In case anyone is having that problem after upgrading to Angular 6 and using cognito, I've written a SO answer that might help: https://stackoverflow.com/a/50377270/2398593 |
We will add this to the polyfills within amplify |
We updated the Amplify documentation to describe how to fix this issue for an Angular 6 app. A more permanent solution will be forthcoming when we are able to update dependencies. |
Why is this issue closed? |
I had this errror too with a Vue app. |
2 years later since this issue was opened, I'm still seeing this error in React app.. I'm following the Amplify tutorials exactly. Am i missing any sort of config? |
@nazmifeeroz Same here, but in a Vue app. Maybe the issue runs deeper? I ended up stumbling upon this thread aws/aws-sdk-js#3673. OP provided what I thought were some interesting nuggets of info. A similar solution to "fixing" the issue is provided there as well, so that may not be helpful; however, maybe it will help someone trying to refine their searching keywords. |
Same problem still happening in June 2021
This workaround from @CihanSari worked well, even using Auth from Amplify.
Why is this closed? |
Why close the issue when it isn't solved. Looking to move away from the amplify stack if this keeps happening! |
Have the same issue using Vue 3.0.5 and aws-amplify 4.1.3 |
thought i'd give amplify a go with Angular 12. Hit this error straight away, Is Amplify useless given this bugs response? |
Getting the same error, but with @aws-sdk/client-s3 Using:
Same workaround header script gets rid of the error, but annoying and wasted a lot of time trying to figure out what was wrong. |
Same workaround works well vite + react + TS projects! Update: Found a better better fix for Vite Projects. Edit the
Works like a charm! |
Angular 13 still facing the same issue. I tried adding polyfill.ts with package.json "@aws-amplify/auth": "^4.5.9" // Latest Error
|
Echoing my disappointment. Aws-amplify basically unusable without workarounds in a Vite project due to |
@Sife-ops - can you please try the workaround mentioned in this comment. Does it resolve your issue? #10242 (comment) |
This comment #10242 (comment) worked for me in my Vite project |
Evaluating Amplify and Angular. Started a brand new vanilla Angular13 project, added Amplify, and am at a dead end with this years-old bug. This concludes the evaluation. |
Hi @shmert - did you try the recommendation mentioned in this comment? #10242 (comment) |
@CihanSari thanks man |
still doesn't work with vue 3 and quasar |
Hi @ZalgirisKaunas to clarify, is the workaround mentioned not working for you with Vue3/Quasar? |
Only adding this to index.html worked |
Got it, thanks for the update and glad you were able to get it working @ZalgirisKaunas |
I had this working for Vite as well, until it caused me a separate issue with Axios where it expected the <script>
if (global === undefined) {
var global = window;
}
</script> |
Have angular 15 and latest version of amplify still stuck. Tried all the solutions none of them work, no script in index, no polyfills , nothing! |
Same w Angular 16 |
@DavithkbY could you please open a new issue with additional context/information on what you are seeing? Thanks! |
I finally managed to fix it! in tsconfig.app.json as: In angular.json in BOTH (!!IMPORTANT!!) builder for TEST and EVERY OTHER BUILDER. My polyfills.ts file which works: (window as any).process = { So just to conclude, I hadn't included the damn polyfills file in every location needed. No one on the internet either told me to include it in the tsconfig files and the other builds(which in hindsight seems pretty logical..) |
Could you please check my fix on the post above |
Thank you man... i really appreciate it. |
Do you want to request a feature or report a bug?
Feature / Bug
What is the current behavior?
A dependencies of Buffer.js is causing an error on global node variable.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than AWS Amplify.
Create a new Angular cli 6 project and add AWS Cognito. Once you import aws-sdk or amazon-cognito-identity-js you'll get an error "Uncaught ReferenceError: global is not defined" from Buffer.js
What is the expected behavior?
Run an Angular 6 project without the dependency of the global node variable
I'm testing an Angular 6 app with AWS Cognito and noticed an error in my console.
After some research I came acros this comment from the Angular CLI team
angular/angular-cli#9827 (comment)
I think when Angular 6 is released, this is going to be an issue
The text was updated successfully, but these errors were encountered: