【问题标题】:AuthError - Error: Amplify has not been configured correctly / AWS cognito, React JSAuthError - 错误:未正确配置 Amplify / AWS cognito,React JS
【发布时间】:2021-11-20 08:39:02
【问题描述】:

我正面临这个问题。安装 amplify-cli、aws-amplify 和 aws-amplify-react 后,无法使用 aws cognito。我的代码 sn-p 如下所示。

import React from 'react';
import { withAuthenticator } from 'aws-amplify-react';
import config from './aws-exports';
function App() {
  return (
    <div>
        <b>Hello World..</b>
    </div>
  );
}

export default withAuthenticator(App, {includeGreetings: true});

我添加了 放大添加身份验证 放大推送

但经常遇到这个问题。

错误图片附在下面..请看一下

【问题讨论】:

    标签: reactjs amazon-web-services amazon-cognito aws-amplify aws-amplify-cli


    【解决方案1】:

    经过大量研究终于解决了这个问题。通过使用以下命令在 react js 应用程序中安装 @aws-amplify/core 包解决了该问题。

    npm i @aws-amplify/core --save --legacy-peer-deps
    
    

    但是在我的情况下安装之后,我收到了错误,因为这个包显示了很多依赖包。因此,在最后添加了所有这些之后,cognito aws 登录/注册问题得到了解决..

    npm i @aws-amplify/storage --save --legacy-peer-deps
    npm i @aws-amplify/interactions --save --legacy-peer-deps
    npm i @aws-amplify/auth --save --legacy-peer-deps
    npm i @aws-amplify/api --save --legacy-peer-deps
    npm i @aws-amplify/analytics --save --legacy-peer-deps
    npm i @aws-amplify/xr --save --legacy-peer-deps
    
    

    【讨论】:

      猜你喜欢
      • 2021-01-30
      • 2020-12-16
      • 2020-12-15
      • 1970-01-01
      • 1970-01-01
      • 2021-07-31
      • 2023-03-22
      • 1970-01-01
      • 2023-03-04
      相关资源
      最近更新 更多