Error: The reference to "global" is undefined and was not caught in the promise

After successfully running my project, I encountered an issue upon installing the aws-sdk package from here.

Despite trying to find solutions online, I have been unable to resolve this problem.

The error message I am facing is:


core.js:1673 ERROR Error: Uncaught (in promise): ReferenceError: global is not defined
ReferenceError: global is not defined
    at Object../node_modules/buffer/index.js (index.js:43)
    at __webpack_require__ (bootstrap:81)
    at Object../node_modules/aws-sdk/lib/browserHashUtils.js (browserHashUtils.js:1)
    at __webpack_require__ (bootstrap:81)
    at Object../node_modules/aws-sdk/lib/browserHmac.js (browserHmac.js:1)
    at __webpack_require__ (bootstrap:81)
    at Object../node_modules/aws-sdk/lib/browserCryptoLib.js (browserCryptoLib.js:1)
    at __webpack_require__ (bootstrap:81)
    at Object../node_modules/aws-sdk/lib/browser_loader.js (browser_loader.js:4)
    at __webpack_require__ (bootstrap:81)
    at resolvePromise (zone.js:814)
    at resolvePromise (zone.js:771)
    ...
    

Answer №1

To ensure compatibility, remember to include the following code snippet in your /src/polyfills.ts file:

// It is necessary for aws-sdk that 'global' exists
(window as any).global = window;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

execute several actions within a single effect

I'm trying to find a way to combine multiple actions into one effect in Angular. Currently, I have to create two separate effects to achieve this: // first effect @Effect() action1$ = this.actions$ .ofType(CoreActionTypes.MY_ACTION) .map(res => ...

Error: Unable to access properties of null (specifically 'writeValue')

My goal is to retrieve an object by its ID, and if the object does not exist, the component will then register the object. However, when the object does exist, it retrieves the object normally, but then throws the same error again. HTML: <div class="c ...

Angular - Set value only if property is present

Check if the 'rowData' property exists and assign a value. Can we approach it like this? if(this.tableObj.hasOwnProperty('rowData')) { this.tableObj.rowData = this.defVal.rowData; } I encountered an error when attempting this, specif ...

What is the most effective method for identifying duplicate values in a multidimensional array using typescript or javascript?

I have a 2D array as shown below: array = [ [ 1, 1 ], [ 1, 2 ], [ 1, 1 ], [ 2, 3 ] ] I am looking to compare the values in the array indexes to check for duplicates. For example array[0] = [1,1]; array[1] = [1,2]; array[2] = [1,1]; We can see that ...

Refresh Ionic 2 Platform

I'm currently working on an Ionic 2 app and whenever I make a change to the .ts code, I find myself having to go through a tedious process. This involves removing the platform, adding the Android platform again, and then running the app in Android or ...

Issue with retrieving relative time using Moment.js - fromNow()

I want to utilize moment.js to display relative time fromNow(), but I am encountering an issue where the values are being rounded and showing higher durations instead of exact completion times. For example, moment().subtract('s',110).fromNow() / ...

What could be the reason for Typescript attempting to interpret files in the `./build` directory as input files?

After struggling for an hour on this issue, I am stuck. The variables outDir and rootDir are set. However, the problem arises when only src is included in include, TypeScript shows the configuration via showConfig, yet it's attempting to compile 4 fi ...

Using TypeScript with React's forwardRef

Here's my code where I have utilized React's forwardRef: interface PropsDummy {} const ProfileMenu = forwardRef<HTMLInputElement, PropsDummy>((props, ref) => { console.log(ref.current); } However, I'm encountering a TypeScript e ...

I am currently encountering challenges while trying to operate my smartadmin theme on angular 2 platform

I recently acquired the SmartAdmin Theme for my project development needs. It worked seamlessly with AngularJS, but I encountered numerous errors when attempting to integrate it with Angular2. I have attached screenshots showing the issues for your referen ...

When the button is clicked, (ngSubmit) will be triggered

In my Angular2 Form Component, I have implemented two buttons with different functionalities. Button Submit: This button submits all the values to the API. Button Add: This button adds an object to an array. Here are the two methods: onSubmit() { this. ...

Changes to base URL in Angular causing caching of index.html for select users

Let me share with you a story involving a version upgrade issue. Our Angular dashboard is hosted on an "Azure App Service Web App". It communicates with a NodeJS backend, which is also served by another Azure instance. So far, we have deployed two releas ...

My local server threw an unexpected error while running my React app: error code 0308010C, signaling an issue with the digital envelope

Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19) at Object.createHash (node:crypto:133:10) at module.exports (/Users/parasnagpal0707/Documents/Projects/StalkHub/node_modules/webpack/lib/ ...

The user callback for @firebase/database encountered an exception. TypeError: Unable to access property 'myID' as it is undefined

After deploying my app to Firebase hosting, some users are encountering this error: @firebase/database: FIREBASE WARNING: Exception was thrown by user callback. TypeError: Cannot read property 'myID' of undefined screenshot https://i.sstatic ...

What is the best way to implement a scroll event in a React application?

Can someone provide guidance on how to properly write the scrollHandler function for this scenario? ` useEffect(() => { document.addEventListener('submit', scrollHandler); return () => document.removeEventListener('scroll', ...

The 'isLoading' property is not found in the type 'UseMutationResult<AxiosResponse<any, any>, Error, void, unknown>'.ts(2339)

I'm currently working on implementing a delete functionality that displays a loading state using the useMutate function from tanstackquery. However, I encountered an issue where the loading state is not shown when I click the delete button, even after ...

Is ngModel the appropriate method for connecting a form to server-side scripts?

Just diving into the world of Angular, I'm embarking on my very first project - a hybrid mobile app using Ionic/Angular. Within my app, each user has their unique notification settings. There are ten different types of notifications that users can to ...

Deactivate multiple textareas within a loop by utilizing JQuery/Typescript and KnockoutJS

I am working on a for loop that generates a series of textareas with unique ids using KO data-binding, but they all share the same name. My goal is to utilize Jquery to determine if all the textareas in the list are empty. If they are, I want to disable al ...

Angular 7 navigation successfully updates the URL, but fails to load the corresponding component

Despite exhausting all other options, I am still facing a persistent issue: when trying to navigate to a different component, the URL changes but the destination component fails to load. Explanation: Upon entering the App, the user is directed to either ...

Updating text inputs in Angular can be done more efficiently using Angular Update

I need to make adjustments to an Angular application so that it can run smoothly on older machines. Is there a more efficient method for updating a text input field without using (keyup) to update after each keystroke? I haven't been able to find any ...

What steps do administrators (coaches) need to take in order to generate a new user (athlete) using Firebase Cloud Functions?

I am currently developing a web application designed for coaches and athletes. The main functionality I am working on is allowing coaches to add athletes to the platform. Once added, these athletes should receive an email containing a login link, and their ...