-1

I have a next.js app which I want to deploy using AWS Amplify hosting. Locally works fine, I can build and start the app properly.

I am using Bitbucket repository to upload files to Amplify which auto detects files to upload every push I make. But it gets stuck at Uploading files even though I set build time out to two hours, anything else goes fine.

P.S This is a warning I get when deploying:

2025-02-12T11:56:53.406Z [WARNING]: ! Unable to write cache: {"code":"ERR_BAD_REQUEST","message":"Request failed with status code 404"})}

.next generated folder is 880MB large.

This is amplify.yml:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build -- --debug
  artifacts:
    baseDirectory: .next


    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

This is .gitignore:

# Node artifact files
node_modules/
dist/

# Compiled Java class files
*.class

# Compiled Python bytecode
*.py[cod]

# Log files
*.log

# Package files
*.jar

# Maven
target/
dist/

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv

.next

.env.local
4
  • Was the .next folder pushed to bitbucket? I think it should be ignored when pushing to the remote repository as it is generated at runtime
    – vht981230
    Commented Feb 19 at 4:59
  • If you don't mind @besart, can you share us your amplify.yml? Commented Feb 21 at 5:56
  • This is amplify.yml version: 1 frontend: phases: preBuild: commands: - npm ci build: commands: - npm run build -- --debug artifacts: baseDirectory: .next files: - '**/*' cache: paths: - node_modules/**/*
    – Besart
    Commented Feb 23 at 9:26
  • Can you edit your question to add your amplify.yml and .gitignore ? Commented Feb 23 at 15:02

1 Answer 1

0

Can you try adding envCache --set stackInfo "" in your amplify.yml. Specifically in your build command.

build:
  commands:
    - envCache --set stackInfo ""
    - npm run build -- --debug

Someone encountered a similar issue as mentioned here.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.