vercel/next.js · error · Error
Invalid distDir provided, distDir can not be an empty…
Error message
Invalid distDir provided, distDir can not be an empty string. Please remove this config or set it to undefined
What it means
Config validation in assignDefaultsAndValidate: distDir was a string but trimmed to length zero. An empty distDir would resolve the build output to the project root itself and can result in project files being deleted in development mode, so it is rejected with instructions to remove the option or set it to undefined.
Solutions
- Remove the empty distDir config or set it to a non-empty string.
Defensive patterns
Strategy: validation
When it happens
Trigger: distDir is set to an empty string.
Common situations: distDir: '' in next.config; remove it or set undefined instead.
AI-assisted analysis of vercel/next.js@34433fd12e (2026-08-19).
Data as JSON: /api/errors/cd4833e57360ed53.
Report an issue: GitHub.
Appendix: source
Thrown at packages/next/src/server/config.ts:396
if (key === 'distDir') {
if (typeof value !== 'string') {
throw new Error(
`Specified distDir is not a string, found type "${typeof value}"`
)
}
const userDistDir = value.trim()
// don't allow public as the distDir as this is a reserved folder for
// public files
if (userDistDir === 'public') {
throw new Error(
`The 'public' directory is reserved in Next.js and can not be set as the 'distDir'. https://nextjs.org/docs/messages/can-not-output-to-public`
)
}
// make sure distDir isn't an empty string as it can result in the provided
// directory being deleted in development mode
if (userDistDir.length === 0) {
throw new Error(
`Invalid distDir provided, distDir can not be an empty string. Please remove this config or set it to undefined`
)
}
}
if (key === 'pageExtensions') {
if (!Array.isArray(value)) {
throw new Error(
`Specified pageExtensions is not an array of strings, found "${value}". Please update this config or remove it.`
)
}
if (!value.length) {
throw new Error(
`Specified pageExtensions is an empty array. Please update it with the relevant extensions or remove it.`
)
}
View on GitHub (pinned to 34433fd12e)