AWS Amplify 和 React Native - 无法解析“@aws-amplify/ui/dist/style.css”

AWS Amplify & React Native - Unable to resolve "@aws-amplify/ui/dist/style.css"

我正在尝试按照 this article 自定义 AWS Amplify UI signin/signup 流程。每次我从 aws-amplify-react 导入任何内容时,我都会收到此错误:

Unable to resolve "@aws-amplify/ui/dist/style.css" from "node_modules/aws-amplify-react/dist/Amplify-UI/Amplify-UI-Components-React.js"

我试过专门安装 @aws-amplify/ui 以及 aws-amplify 版本的其他组合。这是我的 package.json:

的相关部分
...
"aws-amplify": "^1.1.25",
"aws-amplify-react": "^2.3.5",
"aws-amplify-react-native": "^2.1.9",
...

以及我尝试过的特定 UI & auth 的版本:

"@aws-amplify/auth": "^1.2.21",
"@aws-amplify/ui": "^1.0.2",

这是导入语句:

import { ConfirmSignIn, ConfirmSignUp, ForgotPassword, RequireNewPassword, SignIn, SignUp, VerifyContact, withAuthenticator } from 'aws-amplify-react';

非常感谢任何解决此问题的帮助。

今天也 运行 关注这个问题。

问题是使用 aws-amplify-react 而不是 aws-amplify-react-native。 所以继续 npm uninstall react 版本,然后 npm install react-native 版本。

您链接的文档中的评论巧妙地提到了这一点:

import { withAuthenticator } from 'aws-amplify-react'; // or 'aws-amplify-react-native';