Home > Blockchain >  AWS Amplify hosted Nuxt app's build does not fail on error
AWS Amplify hosted Nuxt app's build does not fail on error

Time:10-02

I have a website written with Nuxt js and I am hosting it in AWS Amplify. I have a large issue. When something fails in the nuxt generate command (ex: a JavaScript error within the code I push), the build still works and it produces a broken website. Below is my build command:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm install
        - echo "API_URL=$API_URL" >> .env 
    build:
      commands:
        - npm run generate --fail-on-error
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

I thought --fail-on-error was supposed to force the build to fail, but this is not what I'm seeing.

CodePudding user response:

Using npm run generate --fail-on-error && proceed_the_CI fixed the issue because it allowed to double-check that the previous command is successfully built before going forward.

  • Related