I am trying to deploy a web application using AWS Amplify. The build is failing during the frontend step and is giving this error: CustomerError: Artifact directory doesn't exist: ./build
, below are some logs showing what occurred:
2024-03-02T22:35:33.871Z [INFO]: # Completed phase: preBuild
# Starting phase: build
# Completed phase: build
2024-03-02T22:35:33.915Z [INFO]: ## Build completed successfully
2024-03-02T22:35:33.917Z [INFO]: # Starting caching...
2024-03-02T22:35:33.926Z [INFO]: # Creating cache artifact...
2024-03-02T22:35:48.550Z [INFO]: # Created cache artifact
2024-03-02T22:35:48.635Z [INFO]: # Uploading cache artifact...
2024-03-02T22:35:50.557Z [INFO]: # Uploaded cache artifact
2024-03-02T22:35:50.558Z [INFO]: # Caching completed
2024-03-02T22:35:50.608Z [ERROR]: !!! CustomerError: Artifact directory doesn't exist: ./build
2024-03-02T22:35:50.610Z [INFO]: # Starting environment caching...
2024-03-02T22:35:50.610Z [INFO]: # Uploading environment cache artifact...
2024-03-02T22:35:50.685Z [INFO]: # Uploaded environment cache artifact
2024-03-02T22:35:50.685Z [INFO]: # Environment caching completed
When I run npm run build
locally, it compiles successfully and generates the appropriate files (html, javascript, css, etc.) in a folder named 'build'. I am also able to run npm start
and it compiles successfully.
Here is my yaml file defining the build settings. Note that I set baseDirectory: ./build
:
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands: []
artifacts:
baseDirectory: ./build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Any advice would be much appreciated, thanks.