尝试在 aws amplify 上部署 React 应用程序,但不断收到“未为工件指定基本目录,无法创建构建工件”。

lin*_*ina 3 containers amazon-web-services docker reactjs aws-amplify

我的反应应用程序没有通过构建部分。我能够解决之前的一些错误,但我陷入了这一错误: 2021-10-03T20:15:39.408Z [ERROR]: !!! CustomerError: Base Directory not specified for artifacts, unable to create build artifact..

错误

这是我的构建设置,即 amplify.yml 文件。有谁知道我该如何修复这个错误?

version: 1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - node -v
        - npm run-script build
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
Run Code Online (Sandbox Code Playgroud)

小智 5

发生这种情况的原因是没有 的条目artifacts,其中包含baseDirectoryfileshttps://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.artifacts

frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - node -v
        - npm run-script build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
Run Code Online (Sandbox Code Playgroud)