next build stops because Next.js cannot read revalidate, dynamic or another route option
Your error
⨯ Invalid segment configuration export detected. This can cause unexpected behavior from the configs not being applied. You should see the relevant failures in the logs above. Please fix them to continue.3 more lines it can showFix it fast
Most common cause, 1 of 3The value is a calculation
Write the final number.
// app/blog/page.tsx
export const revalidate = 600 // 10 minutesShort answer
Next.js reads route options such as revalidate, dynamic and runtime by parsing the file at build time, without running it. A value written as arithmetic, an imported constant or a condition cannot be read that way, so the build stops. Write the option as a plain literal like 600 or 'force-dynamic', and move runtime decisions into code.
Which cause do you have?
The last line is only a summary. Scroll up in the build output to the line that names the route and the option; it tells you which of the causes below you have.
npx next build 2>&1 | grep -B1 -A2 "can't recognize the exported"Then find the line you see in this list and open its fix:
- 1The value is a calculation
Unknown identifier "..." at "revalidate", where the identifier is a local variable - 2The value is imported from a shared constants file
Unknown identifier at "revalidate" naming a constant that is exported from another module - 3The option depends on an environment variable or a condition
Unsupported node type "ConditionalExpression" at "dynamic"
What does the error look like?
⨯ Invalid segment configuration export detected. This can cause unexpected behavior from the configs not being applied. You should see the relevant failures in the logs above. Please fix them to continue.⨯ Next.js can't recognize the exported `config` field in route "/s/page": Unknown identifier "secs" at "revalidate".Unknown identifier "TEN_MIN" at "revalidate".Unsupported node type "ConditionalExpression" at "dynamic".
Cause 1 of 3
The value is a calculation
You seeUnknown identifier "..." at "revalidate", where the identifier is a local variable
Check
Look for revalidate = 60 * 10, or a variable defined a few lines above. The parser only accepts a number it can see directly; the Next.js docs give 60 * 10 as an example of a value that is not accepted.
grep -rnE 'export const (revalidate|dynamic|dynamicParams|fetchCache|runtime|preferredRegion|maxDuration)' appFix
Write the final number. A comment keeps the meaning readable.
// app/blog/page.tsx
export const revalidate = 600 // 10 minutesVerify
Run the build again. The route appears in the route table with its revalidate time.
npx next buildConfirmed by nextjs.org
Cause 2 of 3
The value is imported from a shared constants file
You seeUnknown identifier at "revalidate" naming a constant that is exported from another module
Check
A shared constant feels tidy, but the build reads each route file on its own and does not follow the import to find the number.
grep -rnE "export const revalidate = [A-Z_]+" appFix
Repeat the literal in each route file that needs it. If you want one place to change cache times, put the time on the fetch call or the cached function instead, where ordinary code is allowed.
// route file: literal only
export const revalidate = 600
// or keep the shared constant at the data level
import { TEN_MIN } from '@/lib/cache'
const res = await fetch(url, { next: { revalidate: TEN_MIN } })Verify
The build passes and the route still shows the expected revalidate time.
npx next build | grep -E 'Revalidate|○|ƒ'Confirmed by nextjs.org
Cause 3 of 3
The option depends on an environment variable or a condition
You seeUnsupported node type "ConditionalExpression" at "dynamic"
Check
A ternary on process.env, or any expression, is not a constant literal. The value would only be known when the code runs, which is after the build has to decide how to render the route.
grep -rnE "export const dynamic = .*\?" appFix
Pick one literal for the file. If only some requests need dynamic output, leave the segment option out and call connection() in the code path that must wait for a real request.
import { connection } from 'next/server'
export default async function Page() {
if (process.env.LIVE_DATA === '1') {
await connection() // rendered per request from here on
}
return <Dashboard />
}Verify
The build passes, and the route table shows the rendering mode you expect for the environment you built in.
LIVE_DATA=1 npx next buildConfirmed by nextjs.org
How do I stop it coming back?
- Treat route segment options as configuration, not code: literals only.
- Keep shared cache times at the fetch or function level, where variables are allowed.
- Run next build in CI; next dev does not always stop on these values.
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.