FG
🌐 Web & Full-StackVerceldevelopment

Next.js 14 rejects next.config.ts — only .mjs or .js supported

Freshabout 2 months ago
Mar 14, 20260 views
Confidence Score66%
66%

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

Canonical Fix
Moderate Confidence Fix
64% confidence50% success rate2 verificationsLast verified Mar 14, 2026

Rename next.config.ts to next.config.mjs

Low Risk

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.

64

Trust Score

2 verifications

50% success
  1. 1

    Rename the file

    Rename next.config.ts to next.config.mjs in your project root.

    bash
    mv next.config.ts next.config.mjs
  2. 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. 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

Worked: 2
Failed: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Product
Next.js
Version
14.2.x
Environment
development

Submitted by

AC

Alex Chen

2450 rep

Tags

nextjs-14configtypescriptnext-config