How to tell vercel to use .next/standalone folder?

Hello,
I had a build error regarding maximum size of 250 MB.
So I created output: ‘standalone’ folder (45mb) and set root directory : client.next\standalone
But that caused a different error The specified Root Directory “client.next\standalone” does not exist.

On my local machine, I see folder \client.next\standalone )

Do I need to add a build step to vercel.json ?
Can I view the build artifacts ?

Vercel project settings :
build command npx convex deploy --cmd ‘npm run build’
root directory : client.next\standalone

This is a react/next project with clerk and convex.

Hi, Peter! Welcome :smile:

The error “The specified Root Directory “client.next\standalone” does not exist” occurs because the client.next\standalone directory is created during the build process, but Vercel is looking for it before the build starts .

Instead of changing the root directory, you should keep your original root directory (likely client or the directory containing your Next.js app) and use the outputDirectory setting in your vercel.json file . Here’s how:

{
  "outputDirectory": "client/.next/standalone"
}

This tells Vercel where to find your build output after the build process is complete.

Also, ensure your build command in Vercel project settings is correct. It should be something like npx convex deploy --cmd 'npm run build' if you need to deploy Convex before building your Next.js app.

To view build artifacts, after a deployment, go to your project in the Vercel dashboard, click on the deployment, and check the “Source” tab .

Could you give these changes a go?

Hi Pauline,

Thanks for the tip

In the log , I see : Build Completed in /vercel/output [36s]

But I get same error : maximum size of 250 MB

I am using the suggested build command : npx convex deploy --cmd ‘npm run build’

In ‘source’ tab, I don’t see “client/.next” folder - should the folder get created?

Thanks, Peter

Could you share your whole vercel.json config? It might be easier to debug here!

Might also be worth trying:

{
  "outputDirectory": ".next/standalone"
}


Hello, Thanks again for your help.

I tried “.next/standalone” , but same error.

this is my whole vercel.json

( I also build a flask app)

{
    "outputDirectory": "client/.next/standalone",
    "builds": [
      {
        "src": "server/server.py",  "use": "@vercel/python"

      }
    ],
    "routes": [
      {
        "src": "/(.*)", "dest": "server/server.py"
      }
    ]    
}

Thank you for sharing your vercel.json configuration. I see you’re trying to use the Next.js standalone output while also incorporating a Python server. There are a few adjustments we can make to your configuration to get it working correctly:

  1. Keep the outputDirectory as you have it.
  2. Add a builds section to handle both Next.js and Python:
"builds": [
  {
    "src": "client/next.config.js",
    "use": "@vercel/next"
  },
  {
    "src": "server/server.py",
    "use": "@vercel/python"
  }
]
  1. Update your routes to properly direct traffic:
"routes": [
  {
    "src": "/api/(.*)",
    "dest": "server/server.py"
  },
  {
    "src": "/(.*)",
    "dest": "client/$1"
  }
]

If I’m understanding correctly, this setup will build both your Next.js app and Python server, and route requests appropriately between them. Make sure your project structure matches these paths, and that your next.config.js has output: 'standalone' set.

This is a great tip!
(This is my first Next js app - alot of learning )
I got a different error : Error: Specified “src” for “@vercel/next” has to be “package.json” or “next.config.js”
I’ll make that change, and play around with it.
Thanks again, Peter

1 Like