Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

next export is gone: moving to output: 'export'

ErrorThe "next export" command has been removed in favor of "output: export" in next.config.js

Short answer

Next.js 14 removed the next export command. Set output: 'export' in next.config.js and run next build; the static files land in the out folder. If the build then fails, a feature that needs a server is in use, such as cookies, rewrites or the default image loader.

  • Applies to Next.js 15, Next.js 16, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look at your build script. If it still calls next export, that is the whole error.

    grep -n "next export" package.json
  2. 2Match what you see, then jump to its fix

    1. 1The package.json script is next build && next exportThe build script still runs next exportFix
    2. 2Build passes, hosting says the publish directory is missingThe deploy still looks for the old output folderFix
    3. 3The build fails after output: 'export' was added, naming a route, cookies, redirects or imagesThe app uses something a static export cannot serveFix

What does the error look like?

  • The "next export" command has been removed in favor of "output: export" in next.config.js

Cause 1 of 3

The build script still runs next export

1Check

next export was deprecated in 13.3 and removed in 14.0. A deploy that still runs it fails after upgrading.

grep -n "export" package.json next.config.*

2Fix

Turn on the static output in the config and delete the next export step. next build now writes the site to out.

// next.config.js
const nextConfig = {
  output: 'export',
}
module.exports = nextConfig

// package.json
"build": "next build"

3Verify

Build and look for the out folder.

npm run build
ls out

Confirmed by nextjs.org

Did this fix it?

Cause 2 of 3

The deploy still looks for the old output folder

1Check

The static export is written to out by default, unless distDir is set.

grep -n "distDir" next.config.*

2Fix

Point the host's publish directory at out, or set distDir to the folder name the host expects.

// next.config.js
const nextConfig = {
  output: 'export',
  distDir: 'dist', // only if the host needs dist
}
module.exports = nextConfig

3Verify

Rebuild and list the folder.

ls dist

Confirmed by nextjs.org

Did this fix it?

Cause 3 of 3

The app uses something a static export cannot serve

1Check

Static export cannot use cookies, rewrites, redirects or headers in next.config, a proxy, Server Actions, ISR, dynamic routes without generateStaticParams, or the default image loader.

grep -rn "cookies()\|generateStaticParams\|redirects\|rewrites" app next.config.*

2Fix

Remove or replace each one. For example, add generateStaticParams to dynamic routes, and define a custom image loader.

// app/blog/[id]/page.tsx
export async function generateStaticParams() {
  return [{ id: '1' }, { id: '2' }]
}

// next.config.js
const nextConfig = {
  output: 'export',
  images: { loader: 'custom', loaderFile: './my-loader.ts' },
}

3Verify

Run the build; it should finish without errors.

npm run build

Confirmed by nextjs.org

Did this fix it?

How do I stop it coming back?

  • Decide early whether the project needs a server; static export closes that door.
  • Run next build in CI so a removed feature shows up before a release.
  • Use a host that can serve plain files, such as nginx with try_files, for the out folder.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.