升级AWS Amplify至5.3.7后configure方法报错求助
aws-amplify 升级至5.3.7版本后的未解决问题
将NodeJS项目中的aws-amplify库升级至5.3.7版本后,多数破坏性变更问题已修复,但仍存在两个未解决问题。
更新后的package.json文件内容如下:
{ "name": "project", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.4.2", "@fortawesome/free-brands-svg-icons": "^6.4.2", "@fortawesome/free-solid-svg-icons": "^6.4.2", "@fortawesome/react-fontawesome": "^0.2.0", "@types/nprogress": "^0.2.0", "aws-amplify": "^5.3.7", "axios": "^1.4.0", "colors": "^1.4.0", "next": "13.4.16", "nprogress": "^0.2.0", "react": "18.2.0", "react-dom": "18.2.0", "react-dropzone": "^14.2.3", "react-select": "^5.7.4", "sass": "^1.65.1" }, "devDependencies": { "@types/node": "^20.5.0", "@types/react": "18.2.20", "eslint": "8.47.0", "eslint-config-next": "13.4.16", "typescript": "5.1.6" } }
第一个错误出现在代码行 Amplify.configure(AmplifyConfig);,TypeScript提示“property configure does not exist on type typeof....”。配置从单独的TypeScript文件导入:import { AmplifyConfig } from "../configs";,配置内容如下:
export const AmplifyConfig = { Auth: { // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID identityPoolId: "<>", // REQUIRED - Amazon Cognito Region region: "<>", // OPTIONAL - Amazon Cognito Federated Identity Pool Region // Required only if it's different from Amazon Cognito Region identityPoolRegion: "<>", // OPTIONAL - Amazon Cognito User Pool ID userPoolId: "<>", // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string) userPoolWebClientId: "<>", oauth: { domain: "XXXXXXXXX.com", scope: [ "phone", "email", "openid", "profile", "aws.cognito.signin.user.admin", ], redirectSignIn: process.env.PROD_CALLBACK_URL, redirectSignOut: process.env.PROD_SIGNOUT_URL, responseType: "token", // or 'token', note that REFRESH token will only be generated when the responseType is code }, }, ssr: true, };
内容的提问来源于stack exchange,提问作者vinod827
相关产品推荐
相关产品推荐

