deploy next.js to amplify using yarn

Viewed 481

amplify.yaml

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

I am trying to deploy my next.js application aws amplify. I am using yarn instead of npm

Build is success. but it says

This dev.polyverse.app page can’t be foundNo web page was found for the web address:
https://dev.polyverse.app/
HTTP ERROR 404

Please take a look.

2 Answers

I see you have used yarn in the local project. AWS Amplify prefers you to use npm when you are deploying the project. So you can use yarn locally when you are developing it and when you are deploying it to AWS, use npm instead of yarn.

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

This worked for me. You need to use npm

Related