Next.js "Invalid next.config.js options detected" in CI
Next.js validates next.config against a schema on startup. A key that is misspelled, removed, or relocated between versions triggers "Invalid next.config.js options detected" and can fail strict builds.
What this error means
next build prints "Invalid next.config.js options detected:" with "Unrecognized key(s) in object: 'X'" or "Expected ..., received ...", naming the offending option.
⚠ Invalid next.config.js options detected:
⚠ Unrecognized key(s) in object: 'target'
⚠ See more info here: https://nextjs.org/docs/messages/invalid-next-configCommon causes
A removed or renamed option for this Next version
Options like target were removed and others moved out of experimental; carrying them forward across an upgrade fails validation.
A typo in a config key
A misspelled key does not match the schema, so Next reports it as unrecognized.
How to fix it
Align the config with your Next version
- Read which key Next flagged as unrecognized.
- Check the upgrade guide for that version to see if the key moved or was removed.
- Rename, relocate, or delete the key and re-run the build.
// remove options no longer supported, e.g. 'target'
// move stabilized options out of experimental
module.exports = { /* validated keys only */ }Type-check the config
Annotate the config so an editor and tsc flag invalid keys before the build does.
/** @type {import('next').NextConfig} */
const nextConfig = { /* ... */ }
module.exports = nextConfigHow to prevent it
- Follow the upgrade guide for config changes when bumping Next.
- Type-annotate next.config so invalid keys are caught early.
- Remove deprecated options instead of carrying them across versions.