Amplify-console: Amplify not recognizing my artifact directory during deployment.

Created on 13 Dec 2019  路  7Comments  路  Source: aws-amplify/amplify-console

appId: d1ms7jt11oekyc
region: us-east-1

Hello,

I think I have my build settings incorrect. I am having trouble getting my build (baseDirectory) recognized by the deploy step. I am deploying a vanilla react.js app with a typical "npm run build" script that creates a "build" folder. For some reason, Amplify can't locate the build folder even though it's been generated. I even inserted some postBuild commands to ls la the directory contents and confirm the build directory is there.

Below is my log file.

amplify_output_slh.txt

Any insight to this is greatly appreciated.

pending-customer-response question

Most helpful comment

My problem was that variables wasn't recognised in artifacts section and I had a 'cd' command in preBuild. So adding full path it worked.

version: 1.0
env:
variables:
BUILD_FOLDER: app
OUTPUT_FOLDER: dist
frontend:
phases:
preBuild:
commands:
- cd ${BUILD_FOLDER}
- mkdir ./${OUTPUT_FOLDER}
- npm install
- npm audit fix
build:
commands:
- npm run build-release
postBuild:
commands:
- pwd
- ls ${OUTPUT_FOLDER}
artifacts:
baseDirectory: /app/dist
files:
- '/'
cache:
paths:
- node_modules/
/

All 7 comments

hi @slhernandez can you share your buildspec?

Hi @kahdojay. I am no longer using Amplify. Decided to go in a different direction with my deployment. I am going to close this issue. Thanks!

@slhernandez sorry to see you go. Any particular reason why you moved away?

I am having this exact issue, I am trying to host a Nuxt project and for some reason I see the build script being run but not being able to be found right after.

this is what I'm getting in my logs:

# Starting phase: build
# Executing command: npm run build
[email protected] build /codebuild/output/xxx/src/xxxx
nuxt build
Completed phase: build
## Build completed successfully
...
!!! Error: Artifact directory doesn't exist: dist

and this is my build instructions

version: 0.1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths: []

Any idea where this is going wrong? This is just a basic nuxt project, I did not think starting with Amplify would be such an investment.

I tried changing my baseDirectory to '.nuxt' and the build succeeded but I'm getting the error "xxxxx redirected you too many times." This is still the initial setup so I have yet to see my page actually work so I'm not sure if this made things better or worse but it might be a step in the right direction.

My problem was that variables wasn't recognised in artifacts section and I had a 'cd' command in preBuild. So adding full path it worked.

version: 1.0
env:
variables:
BUILD_FOLDER: app
OUTPUT_FOLDER: dist
frontend:
phases:
preBuild:
commands:
- cd ${BUILD_FOLDER}
- mkdir ./${OUTPUT_FOLDER}
- npm install
- npm audit fix
build:
commands:
- npm run build-release
postBuild:
commands:
- pwd
- ls ${OUTPUT_FOLDER}
artifacts:
baseDirectory: /app/dist
files:
- '/'
cache:
paths:
- node_modules/
/

@koprinkov thank you, this worked for my team.

For clarity: the docs mention here that when building from a subdirectory,

"After you run the cd command, it applies to all stages of your build so you don鈥檛 need to repeat the command in separate phases."

Once the phases are finished (like in your artifacts for the baseDirectory) the full path from root must be included (ie: /app/dist/ as pointed out above)

Was this page helpful?
0 / 5 - 0 ratings