amazon web services – NextJS with Aws Amplify deployment error

Does anyone has tried AWS-Amplify for next.js deployment? I am getting this error always that “yarn build” successful but didn’t deployed and failed.

enter image description here

Git repo is configured with auto-deployment and YML file for aws-amplify is below.

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - rm -rf node_modules
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*