Angular 10-AWS Amplify Auth-AuthError-错误:Amplify配置不正确

问题描述

将SPA应用程序部署到AWS Amplify上,并启用Auth。低于错误

enter image description here

package.json

"dependencies": {
        "@angular/animations": "^10.0.14","@angular/cdk": "^8.1.1","@angular/common": "^10.0.14","@angular/compiler": "^10.0.14","@angular/core": "^10.0.14","@angular/flex-layout": "^10.0.0-beta.32","@angular/forms": "^10.0.14","@angular/material": "^8.1.1","@angular/material-moment-adapter": "8.2.1","@angular/platform-browser": "^10.0.14","@angular/platform-browser-dynamic": "^10.0.14","@angular/router": "^10.0.14","@aws-amplify/ui-angular": "^0.2.15","angular-in-memory-web-api": "0.5.4","aws-amplify": "^3.0.24","brace": "^0.11.1","core-js": "^3.1.4","file-saver": "^2.0.2","fs-extra": "^9.0.0","hammerjs": "^2.0.8","jasmine-reporters": "^2.3.2","jquery": "^3.4.1","lodash-es": "^4.17.15","moment": "2.24.0","ng2-search-filter": "^0.5.1","ngx-dropzone": "^2.1.1","oidc-client": "^1.9.1","popper.js": "^1.15.0","protractor-html-reporter-2": "^1.0.4","protractor-jasmine2-screenshot-reporter": "^0.5.0","rxjs": "^6.6.2","uuid": "^3.3.3","web-animations-js": "2.3.2","zone.js": "~0.10.3"
    },"devDependencies": {
        "@angular-devkit/build-angular": "^0.1000.8","@angular-devkit/build-ng-packagr": "~0.1000.8","@angular/cli": "~10.0.8","@angular/compiler-cli": "^10.0.14","@angular/language-service": "^10.0.14","@types/jasmine": "~3.3.13","@types/jasminewd2": "~2.0.6","@types/jquery": "^3.3.29","@types/lodash": "^4.14.136","@types/node": "^12.6.9","codelyzer": "^5.0.1","jasmine-core": "~3.4.0","jasmine-spec-reporter": "^4.2.1","karma": "~4.2.0","karma-chrome-launcher": "~3.0.0","karma-coverage-istanbul-reporter": "~2.0.5","karma-jasmine": "~2.0.1","karma-jasmine-html-reporter": "^1.4.2","ng-packagr": "^10.1.0","protractor": "~5.4.2","ts-node": "~8.3.0","tsickle": "^0.38.1","tslib": "^2.0.1","tslint": "~5.18.0","typescript": "~3.9.7","webpack-bundle-analyzer": "^3.3.2"
    }

abcd.module.ts

enter image description here

main.ts

enter image description here

我能得到任何帮助吗!

解决方法

这是我的坏事。 当我将“ aws-exports.js”重命名为“ aws-exports.ts”时,“ aws-exports.ts”文件中的内容如下所示

const awsmobile = {
"aws_project_region": "ap-southeast-2"
};
export default awsmobile;

这是错误的(上面一个)。应该是下面的

const awsmobile = {
  "aws_project_region": "ap-southeast-2","aws_cognito_identity_pool_id": "ap-southeast-2:a3346e2c-xxxxxxx-xxxx-xxxx","aws_cognito_region": "ap-southeast-2","aws_user_pools_id": "ap-southeast-xxxxxxxxx","aws_user_pools_web_client_id": "xxxxxxxxxxxxxx","oauth": {}
};