【问题标题】:NextJS with Aws Amplify deployment errorNextJS 与 Aws Amplify 部署错误
【发布时间】:2021-08-25 20:31:57
【问题描述】:

有人尝试过使用 AWS-Amplify 进行 next.js 部署吗?我总是收到这个错误,“纱线构建”成功但没有部署和失败。

Git repo 配置了自动部署,下面是 aws-amplify 的 YML 文件。

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - rm -rf node_modules
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

【问题讨论】:

  • 请帮忙分享你 package.json 中的脚本部分
  • 您的问题最终解决了吗?
  • Amplify 通常很难调试,因为它就像一个黑匣子。查看 SST,它使用由 CloudFormation 模板支持的 CDK 将 Next.js 应用程序部署到您的 AWS 账户。因此,您可以完全控制正在构建和部署的内容。它与 Next.js 11 完全兼容。这是一个示例 serverless-stack.com/examples/…

标签: amazon-web-services aws-lambda next.js aws-amplify aws-serverless


【解决方案1】:

在你的构建中使用这个 yaml 文件

version: 1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: public
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

【讨论】:

    猜你喜欢
    • 2022-10-01
    • 1970-01-01
    • 2023-03-04
    • 2020-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-07
    • 2021-09-23
    相关资源
    最近更新 更多