1

So I have created a Nextjs 14 application in Javascript and its staging environment is deployed on Vercel while the production environment is on AWS Amplify.

I am using next-pwa to convert this application to a PWA.

When I run npm run build and npm run start on local machine it is working fine, but giving issues on both staging and production servers.

Error on Vercel:

Error: The file "/vercel/path0/.next/routes-manifest.json" couldn't be found. This is often caused by a misconfiguration in your project.

Error on AWS Amplify:

[ERROR]: !!! CustomerError: Can't find required-server-files.json in build output directory

Changes I did:

I tried changing the configuration of next.config.js but it is not working as expected. I also did some tweaks in my manifest file and Next.js 14 metadata configuration but no luck

1 Answer 1

0

I hope you have resolved your issue already, but in case you haven't:

Are you using a monorepo by any chance?

My issue was, that I was using a monorepo and had all my node_modules/package.json in the root folder and not in the workspaces/dashboard folder.

I ended up solving the issue this way:

When creating the application on AWS Amplify, enable to Monorepo option and I entered workspaces/dashboard as the Monorepo root directory.

My amplify.json is the following:

version: 1
applications:
  - appRoot: workspaces/dashboard
    frontend:
      phases:
        preBuild:
          commands:
            - cd ../..
            - npm ci
        build:
          commands:
            - npm run build:css
            - cd workspaces/dashboard
            - npx next build
      artifacts:
        baseDirectory: .next
        files:
          - '**/*'
      cache:
        paths:
          - node_modules/**/*

So as you can see, in the prebuild option I use cd ../.. to enter the root directory and install the dependencies. Then ill go back to the workspaces/dashboard directory and run the build command.

Hope this helps!

Sign up to request clarification or add additional context in comments.

1 Comment

Hi, the issue didn't resolve yet but it its priority changes to low. I am not using any monorepo. Just a simple nextjs application

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.