{"record":{"id":"2b7907df301ee2d1","repo":"vercel/next.js","slug":"specified-distdir-is-not-a-string-found-type-t","errorCode":null,"errorMessage":"Specified distDir is not a string, found type \"${typeof value}\"","messagePattern":"Specified distDir is not a string, found type \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":380,"sourceCode":"      )\n    }\n    if (typeof userConfig.trailingSlash === 'undefined') {\n      userConfig.trailingSlash = (userConfig as any).exportTrailingSlash\n    }\n    delete (userConfig as any).exportTrailingSlash\n  }\n\n  const config = Object.keys(userConfig).reduce<{ [key: string]: any }>(\n    (currentConfig, key) => {\n      const value = (userConfig as any)[key]\n\n      if (value === undefined || value === null) {\n        return currentConfig\n      }\n\n      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          )","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/vercel/next.js/blob/34433fd12ee8074ea3f47af9f36255c7390d0301/packages/next/src/server/config.ts#L362-L398","documentation":"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.","triggerScenarios":"distDir in next.config is not a string.","commonSituations":"Setting distDir to a number, boolean, or object in next.config.","solutions":["Set distDir to a string in next.config.js."],"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"}