{"record":{"id":"cd4833e57360ed53","repo":"vercel/next.js","slug":"invalid-distdir-provided-distdir-can-not-be-an-em","errorCode":null,"errorMessage":"Invalid distDir provided, distDir can not be an empty string. Please remove this config or set it to undefined","messagePattern":"Invalid distDir provided, distDir can not be an empty string\\. Please remove this config or set it to undefined","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":396,"sourceCode":"      if (key === 'distDir') {\n        if (typeof value !== 'string') {\n          throw new Error(\n            `Specified distDir is not a string, found type \"${typeof value}\"`\n          )\n        }\n        const userDistDir = value.trim()\n\n        // don't allow public as the distDir as this is a reserved folder for\n        // public files\n        if (userDistDir === 'public') {\n          throw new Error(\n            `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`\n          )\n        }\n        // make sure distDir isn't an empty string as it can result in the provided\n        // directory being deleted in development mode\n        if (userDistDir.length === 0) {\n          throw new Error(\n            `Invalid distDir provided, distDir can not be an empty string. Please remove this config or set it to undefined`\n          )\n        }\n      }\n\n      if (key === 'pageExtensions') {\n        if (!Array.isArray(value)) {\n          throw new Error(\n            `Specified pageExtensions is not an array of strings, found \"${value}\". Please update this config or remove it.`\n          )\n        }\n\n        if (!value.length) {\n          throw new Error(\n            `Specified pageExtensions is an empty array. Please update it with the relevant extensions or remove it.`\n          )\n        }\n","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/vercel/next.js/blob/34433fd12ee8074ea3f47af9f36255c7390d0301/packages/next/src/server/config.ts#L378-L414","documentation":"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.","triggerScenarios":"distDir is set to an empty string.","commonSituations":"distDir: '' in next.config; remove it or set undefined instead.","solutions":["Remove the empty distDir config or set it to a non-empty string."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"34433fd12ee8074ea3f47af9f36255c7390d0301","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}