【问题标题】:AWS amplify deploy failure due to aws-exports由于 aws-exports,AWS 放大部署失败
【发布时间】:2020-04-29 16:27:41
【问题描述】:

我正在尝试将我的 reactJs 应用程序部署到 Amplify。我将我的 Github 连接到 Amplify。在部署期间,它在构建步骤显示以下错误:

2020-01-07T19:35:22.127Z [INFO]: Failed to compile.
2020-01-07T19:35:22.129Z [INFO]: ./src/index.js
                                 Cannot find file './aws-exports' in './src'.
2020-01-07T19:35:22.149Z [WARNING]: error Command failed with exit code 1.
2020-01-07T19:35:22.150Z [INFO]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2020-01-07T19:35:22.155Z [ERROR]: !!! Build failed
2020-01-07T19:35:22.239Z [ERROR]: !!! Non-Zero Exit Code detected
2020-01-07T19:35:22.239Z [INFO]: # Starting environment caching...

发生这种情况是因为 .gitignore 忽略了 aws-exports。 有人可以在不提交 aws-exports 的情况下告诉我这个问题的解决方案是什么吗?

【问题讨论】:

标签: reactjs amazon-web-services serverless aws-amplify


【解决方案1】:

我在第一次构建时遇到了同样的问题。

Amplify 文档没有具体说明在使用 Amplify 控制台时应如何维护构建,但对我有用的例程是:

当您成功运行amplify push 命令时,您会生成您的aws-exports 文件。

aws-exports.js 文件 此文件仅为 JavaScript 生成 项目。它包含所有类别的综合输出 并且放在用户(开发者)的src目录下 在初始化过程中指定。每次成功后更新 执行放大推送命令,该命令已创建或更新 云资源。

基于此,我在 Amplify 控制台中更新了我的配置以部署我的后端。你可以在https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html了解如何配置自己的

backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple

后端构建完成后,将为我的下一个工作生成文件,即使用 aws-exports 文件的前端构建。

注意:如果您使用的是 eslint,则文件输出格式可能会出现问题。你可以在你的前端preBuild添加一个eslint --fix命令

更新:正如lucdenz 提到的,您还需要设置一个service role

我使用的来源:

【讨论】:

猜你喜欢
  • 2017-01-01
  • 1970-01-01
  • 2021-06-21
  • 2021-11-03
  • 2021-06-05
  • 2019-04-07
  • 1970-01-01
  • 2016-07-10
  • 2016-09-05
相关资源
最近更新 更多