Next.js "Invalid next.config.js options" - Fix in CI
Next validates next.config.js against its schema. A key that was removed, renamed, moved out of experimental, or given the wrong type fails the build.
What this error means
The build prints Invalid next.config.js options detected and lists the unrecognized or misplaced keys.
next
⚠ Invalid next.config.js options detected:
Unrecognized key(s) in object: 'swcMinify'
'experimental.appDir' has been removed.
See more info here: https://nextjs.org/docs/messages/invalid-next-configCommon causes
Key removed or renamed across versions
A Next upgrade removed or moved a config option (e.g. an experimental flag that became stable).
Wrong value type
An option received a string where an object/boolean was expected.
How to fix it
Remove or migrate the invalid key
- Check the linked docs for the key, then delete it or move it to its new home.
next.config.js
// next.config.js - remove stale keys, move stabilized ones out of experimental
module.exports = { /* valid options only */ };Match the upgrade guide
- Follow the Next upgrade guide for the version you moved to and adjust config keys accordingly.
How to prevent it
- Read the Next upgrade guide when bumping majors and reconcile config keys.
- Keep next.config.js minimal so schema drift is easy to spot.
Frequently asked questions
What causes "Invalid config"?
A Next upgrade removed or moved a config option (e.g. an experimental flag that became stable).
How do I fix Invalid config?
Remove or migrate the invalid key
Related guides
Next.js "Image Optimization requires" - Fix in CIFix Next.js image optimization errors in CI - a static export or unconfigured remote host means next/image ca…
Next.js "Module not found: Can't resolve" - Fix in CIFix "Module not found: Can't resolve" during next build in CI - a missing dependency, a wrong tsconfig path a…
Next.js ENOENT .next/build-manifest - Fix in CIFix "ENOENT .next/build-manifest.json" in CI - the build artifact is missing because the build did not run, w…