我正在尝试通过遵循this article来定制AWS Amplify UI登录/注册过程。每次我从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和身份验证的版本:
"@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';
对于解决此问题的任何帮助,我们将不胜感激。
答案 0 :(得分:2)
今天也碰到了这个问题。
问题是使用aws-amplify-react
而不是aws-amplify-react-native
。
因此,继续执行npm卸载react版本,然后npm安装react-native版本。
在您链接的文档中巧妙地提到了这一点:
import { withAuthenticator } from 'aws-amplify-react'; // or 'aws-amplify-react-native';