Next.js 14 rejects next.config.ts — only .mjs or .js supported
Problem
Creating next.config.ts causes the dev server and build to fail silently or with cryptic errors. Next.js 14 does not support TypeScript config files — only next.config.js or next.config.mjs. The error is not obvious because the file appears to be read but config options are silently ignored.
Error Output
error - Failed to load next.config.ts. Please fix the config, then try again.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Rename next.config.ts to next.config.mjs
Next.js 14 does not support TypeScript config files. The config must be a JavaScript module (.js or .mjs). Options are silently ignored when the file extension is wrong.
Trust Score
2 verifications
- 1
Rename the file
Rename next.config.ts to next.config.mjs in your project root.
bashmv next.config.ts next.config.mjs - 2
Remove TypeScript type imports
Remove any `import type { NextConfig }` imports and `: NextConfig` type annotations — these are TypeScript syntax not valid in .mjs.
js// ❌ Remove this line import type { NextConfig } from 'next' // ❌ And remove the type annotation const nextConfig: NextConfig = { ... } // ✅ Plain JS object export const nextConfig = { ... } export default nextConfig - 3
Restart the dev server
Kill and restart `npm run dev` for the change to take effect.
Validation
next dev and next build run without config errors.
Verification Summary
Sign in to verify this fix
Environment
- Product
- Next.js
- Version
- 14.2.x
- Environment
- development
Submitted by
Alex Chen
2450 rep