Files
vercel/errors/now-next-no-serverless-pages-built.md
Don Alvarez 10bc74904c [docs] Improve docs for @vercel/next no pages built message (#9494)
After many hours of debugging, I tracked down that having an old Node
version (eg 14.x) listed in your Vercel project settings can result in
the build step failing with a confusing and unhelpful error message
"`@vercel/next` No Serverless Pages Built". Note that this is a case
where it "can" cause it to fail, including with NextJS 13.1.6 and Vercel
CLI 28.16.2, but it is not guaranteed to fail. I have six NextJS
projects. They have identical next.config.js, tsconfig.json,
eslintrc.js, and .gitignore files, and other than a few seemingly
non-critical dependencies they have identical package.json files. Four
of the six consistently built and deployed in the cloud without issue.
Two consistently failed to build in the cloud. All built successfully
locally including using vercel build locally, and all would vercel
deploy --prebuilt successfully. Switching all the vercel cloud project
settings from Node 14.x to Node 18.x enabled all the projects to build
and deploy successfully in the vercel cloud without needing local vercel
build and local vercel deploy --prebuilt steps.

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-02-21 11:32:03 -05:00

1.4 KiB

@vercel/next No Serverless Pages Built

Why This Error Occurred

This error occurs when your application is not configured for Serverless Next.js build output.

Possible Ways to Fix It

In order to create the smallest possible lambdas Next.js has to be configured to build for the serverless target.

  1. Serverless Next.js requires Next.js 8 or later, to upgrade you can install the latest version:
npm install next --save
  1. Check Node.js Version in your Project Settings. Using an old or incompatible version of Node.js can cause the Build Step to fail with this error message.

  2. Add the now-build script to your package.json [deprecated]

{
  "scripts": {
    "now-build": "next build"
  }
}
  1. Add target: 'serverless' to next.config.js [deprecated]
module.exports = {
  target: 'serverless',
  // Other options
};
  1. Remove distDir from next.config.js as @vercel/next can't parse this file and expects your build output at /.next

  2. Optionally make sure the "src" in "builds" points to your application package.json

{
  "version": 2,
  "builds": [{ "src": "package.json", "use": "@vercel/next" }]
}
  1. Make sure you have the correct Node.js version selected for your build step in your project settings (https://vercel.com/[username]/[project]/settings)