Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws-sdk: crash after updating from angular5 to angular6

I just updated to Angular 6.0 from Angular 5.2, my code now break with this error:

core.js:1601 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 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)

anybody knows the problem? I have tried ng update but seems like aws-sdk-js doesn’t provide the schematics for updating

like image 747
Zennichimaro Avatar asked May 10 '18 01:05

Zennichimaro


2 Answers

Add following to polyfills.ts

// aws-sdk requires global to exist
(window as any).global = window;
like image 71
louislarry Avatar answered Nov 17 '22 04:11

louislarry


There is a workaround until this issue is resolved,

try adding in your index.html head tag the following

<script>
  if (global === undefined) {
    var global = window;
  }
</script>
like image 11
Daniel Netzer Avatar answered Nov 17 '22 04:11

Daniel Netzer