尝试使用 amplify 身份验证创建 React 应用程序,但遇到此错误
找不到模块:无法解析“..\node_modules@aws-amplify\api\lib-esm”中的“@aws-amplify/core”
我一直在引用这两个链接:
- https://dev.to/dabit3/the-complete-guide-to-user-authentication-with-the-amplify-framework-2inh
- https://docs.amplify.aws/lib/auth/getting-started/q/platform/js
我已经尝试过什么:
- 删除node_modules并重新安装项目
- 尝试使用 npm 显式安装 @aws-amplify/core(这会引发单独的错误)
感谢任何帮助:)
最佳答案
我在使用 AWS Datastore 时遇到了这个问题,它也依赖于 @amplify/core。我是这样解决的:
npm i @aws-amplify/core --save --legacy-peer-deps
react 组件:
import Amplify from "@aws-amplify/core
在我的情况下,需要旧版对等 deps 标志,因为安装 React 版本高于 amplify/core 所需的版本。如果您还没有这样做,您可能还需要首先amplify init
或amplify pull
。
关于reactjs - 找不到模块 : Can't resolve '@aws-amplify/core' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67769245/