未捕获(承诺):ReferenceError:全局未定义

时间:2019-11-04 12:43:31

标签: angular typescript aws-sdk node-modules

在我安装aws-sdk(链接:https://www.npmjs.com/package/aws-sdk)之前,我的项目运行良好。

我尝试了google ..但无法解决此问题。.

我遇到此错误:

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) at zone.js:873 at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:3811) at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188) at drainMicroTaskQueue (zone.js:595)

1 个答案:

答案 0 :(得分:0)

请通过添加以下内容来更新 /src/polyfills.ts

// aws-sdk requires global to exist
(window as any).global = window;