This error occurs when your application is not configured for Serverless Next.js build output.
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
latest
version:
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-build
script to yourpackage.json
[deprecated]
{
"scripts": {
"now-build": "next build"
}
}
- Add
target: 'serverless'
tonext.config.js
[deprecated]
module.exports = {
target: 'serverless',
// Other options
};
-
Remove
distDir
fromnext.config.js
as@vercel/next
can'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
)