{"record":{"id":"43bf09a2eb6f5c95","repo":"vercel/next.js","slug":"configuring-next-js-via-basename-unsupportedcon","errorCode":null,"errorMessage":"Configuring Next.js via '${basename(unsupportedConfig)}' is not supported. Please replace the file with 'next.config.js', 'next.config.mjs', or 'next.config.ts'.","messagePattern":"Configuring Next\\.js via '(.+?)' is not supported\\. Please replace the file with 'next\\.config\\.js', 'next\\.config\\.mjs', or 'next\\.config\\.ts'\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":2213,"sourceCode":"    }\n\n    return [finalConfig, meta]\n  } else {\n    const configBaseName = basename(CONFIG_FILES[0], extname(CONFIG_FILES[0]))\n    const unsupportedConfig = findUp.sync(\n      [\n        `${configBaseName}.cjs`,\n        `${configBaseName}.cts`,\n        // TODO: Remove `as any` once we bump @types/node to v22.10.0+\n        ...((process.features as any).typescript ? [] : ['next.config.mts']),\n        `${configBaseName}.json`,\n        `${configBaseName}.jsx`,\n        `${configBaseName}.tsx`,\n      ],\n      { cwd: dir }\n    )\n    if (unsupportedConfig?.length) {\n      throw new Error(\n        `Configuring Next.js via '${basename(\n          unsupportedConfig\n        )}' is not supported. Please replace the file with 'next.config.js', 'next.config.mjs', or 'next.config.ts'.`\n      )\n    }\n  }\n\n  const clonedDefaultConfig = cloneObject(defaultConfig) as NextConfig\n\n  enforceExperimentalFeatures(clonedDefaultConfig, {\n    isDefaultConfig: true,\n    configuredExperimentalFeatures,\n    debugPrerender,\n    phase,\n  })\n\n  // always call assignDefaults to ensure settings like\n  // reactRoot can be updated correctly even with no next.config.js","sourceCodeStart":2195,"sourceCodeEnd":2231,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L2195-L2231","documentation":"Thrown at config.ts:2212 when Next.js cannot find a supported config file but does find one with an unsupported extension. The `findUp` search looks for `next.config.cjs`, `next.config.cts`, `next.config.mts` (only when Node's TypeScript feature is disabled), `next.config.json`, `next.config.jsx`, and `next.config.tsx`. Only `.js`, `.mjs`, and `.ts` are supported.","triggerScenarios":"Naming the config `next.config.json`, `next.config.cjs`, `next.config.tsx`, `next.config.jsx`, or `next.config.mts` (on a non-TypeScript Node).","commonSituations":"Renaming the file during a tooling change; committing a JSON copy of the config; scaffolding from a template that used a non-standard extension; migrating to TypeScript and using `.mts` instead of `.ts`.","solutions":["Rename the config file to `next.config.js`, `next.config.mjs`, or `next.config.ts`.","If you have multiple config files, delete the unsupported one so only the supported name remains.","For a JSON-style config, convert it to a `.js`/`.mjs` module that exports the object."],"exampleFix":"// before: file named next.config.json\n// after: rename to next.config.js and use module.exports = { ... }","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nconst supported = ['next.config.js','next.config.mjs','next.config.ts'];\nif (!supported.some(existsSync)) {\n  throw new Error('Rename config to a supported extension');\n}","typeGuard":"function isSupportedConfigName(name: string): boolean {\n  return ['next.config.js','next.config.mjs','next.config.ts'].includes(name);\n}","tryCatchPattern":null,"preventionTips":["Name the config file `next.config.js`, `.mjs`, or `.ts` only.","Delete JSON/cjs/tsx copies before starting the dev server."],"tags":["config","filesystem","initialization"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}