aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
461 stars 116 forks source link

Amplify not recognizing React app build directory code: MissingBuildArtifacts #3936

Closed samgates3 closed 6 months ago

samgates3 commented 6 months ago

Before opening, please confirm:

Amplify Hosting feature

Build settings, Deployments

Is your feature request related to a problem? Please describe:

For a React 18 app

Build fails at the deploy phase, giving the Build artifacts not found error. I had not made any changes to build settings before this issue and have since tried a number of variations I have seen others use from other issues for the baseDirectory path including:

build /build ./build /app-name/build ./app-name/build

all give the same error.

Screenshot 2024-05-31 at 11 53 51 AM

Here are my build settings:

Default build image

version: 1
backend:
  phases:
    build:
      commands:
        - npm i -S graphql-ttl-transformer
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

I have also used - ls command after the build to confirm the build directory is created and all the files are there

Describe how you'd like this feature to work

I'd like to see what changes I can make to get this issue resolved.

github-actions[bot] commented 6 months ago

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

samgates3 commented 6 months ago

I was finally able to find a solution that worked on discord.

The platform was set to WEB_DYNAMIC somehow.

Using aws cli command: aws amplify update-app <APP_ID> --platform WEB --region <REGION> to set the platform to WEB. Then redeployed and everything worked as it did previously.

I don't know if the platform had always been set to WEB_DYNAMIC or WEB, but I did recently add a new branch for a migration to use NextJS and deployed that (it failed, likely because I will have to migrate to use the newer WEB_COMPUTE platform but that will be an issue for another day) and I wonder if that caused the platform to change if it changed at all?

github-actions[bot] commented 6 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] commented 6 months ago

This issue has been automatically locked.