bee*_*est 6 amazon-cognito angular aws-amplify
我正在测试从 Angular 到 Cognito 用户池的 AWS Amplify,如下所示:
https://docs.amplify.aws/lib/restapi/getting-started/q/platform/js
Angular 应用程序已成功编译,但在 Chrome 控制台中抛出异常:
index.js:43 Uncaught ReferenceError: global is not defined
at Object../node_modules/buffer/index.js (index.js:43)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/amazon-cognito-identity-js/es/AuthenticationHelper.js (AuthenticationHelper.js:1)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/amazon-cognito-identity-js/es/index.js (index.js:1)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/@aws-amplify/auth/lib-esm/Auth.js (Auth.js:1)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/@aws-amplify/auth/lib-esm/index.js (index.js:1)
at __webpack_require__ (bootstrap:84)
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
gle*_*enn 14
AWS 文档建议添加
(window as any).global = window;
(window as any).process = {
env: { DEBUG: undefined },
};
Run Code Online (Sandbox Code Playgroud)
到src/polyfills.ts
这在我的项目中发挥了作用。
bee*_*est 12
<script>
var global = global || window;
var Buffer = Buffer || [];
var process = process || {
env: { DEBUG: undefined },
version: []
};
</script>
Run Code Online (Sandbox Code Playgroud)
或添加到末尾 polyfills.ts
(window as any).global = window;
(window as any).process = {
env: { DEBUG: undefined },
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1452 次 |
| 最近记录: |