【问题标题】:Unable to resolve "./aws-exports" from "App.js"无法从“App.js”解析“./aws-exports”
【发布时间】:2023-03-18 06:39:01
【问题描述】:

我用awsamplify 构建一个应用程序已经有一段时间了。今天我决定进行一些测试,当我这样做时

npm run start-web

一切正常。现在我继续使用 Expo 运行移动测试并运行

npm run ios & npm run android

这两个都返回了以下错误。

Unable to resolve "./aws-exports" from "App.js"

Building JavaScript bundle: error

我的问题类似于下面的问题,只是它的amplify 而不是awsmobile

https://github.com/aws-amplify/amplify-js/issues/669

Deos 有人知道我可以做些什么来解决这个问题吗?

非常感谢!

我只是删除了一些未使用的导入并将错误更改为这个

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

【问题讨论】:

  • 你运行amplify init和amplify push了吗?
  • 是的,我都跑了
  • 你能从你的项目中找到aws-exports.js吗?
  • 实际上没有检查,因为 web 部件工作我认为它必须在那里让我检查
  • 它在 .gitignorefile 中列出,但除此之外它不是

标签: reactjs react-native expo aws-amplify


【解决方案1】:

AWS 文档中几乎没有提到:

  • 要设置本地开发文件夹,请从现有的放大存储库中使用 amplify env pull,

    它会从服务器“拉”./aws-exports.js,这是推送到那里的最新消息, 类似于 git push 和 git pull 但用于放大环境

  • 确实,放大推送会创建./aws-exports.js 文件, 但它也会将其“推送”到服务器,覆盖那里的所有内容。

  • amplify status也是一个方便的命令,类似于git status

【讨论】:

    【解决方案2】:

    我运行了放大 env pull 然后在 ./src/aws-exports.js 中找到它

    不确定拉动是否做到了,或者它是否一直存在,但这是针对现有的世博会项目

    【讨论】:

      【解决方案3】:

      配置您的项目,使用终端转到主文件夹and amplify init 来配置您的项目

      amplify init
      
      Do you to use an existing environment? (Y/n) Y
      
      Choose the environment you would like to use: dev
      
      Choose your default editor: Visual Studio Code
      
      Choose the type of app you're building: javascript
      
      What javascript framework you're using: ionic
      
      Source Directory Path: src
      
      Distribution Directory Path: www
      
      Build Command: npm run-script build
      
      Do you want to use an AWS profile? Y
      
      Please choose the profile you want to use: select your personal IAM profile
      

      【讨论】:

        猜你喜欢
        • 2022-10-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-05
        • 1970-01-01
        • 1970-01-01
        • 2022-10-24
        相关资源
        最近更新 更多