vercel/next.js · error · Error
Specified distDir is not a string, found type
Error message
Specified distDir is not a string, found type "${typeof value}" What it means
Config validation in assignDefaultsAndValidate: while reducing over the user's config keys, the distDir key was checked with typeof and found to be a non-string. distDir must be a directory path string; the received type is named so the offending next.config.js value can be corrected.
Solutions
- Set distDir to a string in next.config.js.
Defensive patterns
Strategy: validation
When it happens
Trigger: distDir in next.config is not a string.
Common situations: Setting distDir to a number, boolean, or object in next.config.
AI-assisted analysis of vercel/next.js@34433fd12e (2026-08-19).
Data as JSON: /api/errors/2b7907df301ee2d1.
Report an issue: GitHub.
Appendix: source
Thrown at packages/next/src/server/config.ts:380
)
}
if (typeof userConfig.trailingSlash === 'undefined') {
userConfig.trailingSlash = (userConfig as any).exportTrailingSlash
}
delete (userConfig as any).exportTrailingSlash
}
const config = Object.keys(userConfig).reduce<{ [key: string]: any }>(
(currentConfig, key) => {
const value = (userConfig as any)[key]
if (value === undefined || value === null) {
return currentConfig
}
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`
)View on GitHub (pinned to 34433fd12e)