mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 04:22:01 +00:00
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>
1.4 KiB
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.
- Serverless Next.js requires Next.js 8 or later, to upgrade you can install the
latestversion:
npm install next --save
-
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.
-
Add the
now-buildscript to yourpackage.json[deprecated]
{
"scripts": {
"now-build": "next build"
}
}
- Add
target: 'serverless'tonext.config.js[deprecated]
module.exports = {
target: 'serverless',
// Other options
};
-
Remove
distDirfromnext.config.jsas@vercel/nextcan't parse this file and expects your build output at/.next -
Optionally make sure the
"src"in"builds"points to your applicationpackage.json
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@vercel/next" }]
}
- Make sure you have the correct Node.js version selected for your build step in your project settings (
https://vercel.com/[username]/[project]/settings)