vercel/next.js · error · Error

Specified pageExtensions is not an array of strings, found "

Error message

Specified pageExtensions is not an array of strings, found "${ext}" of type "${typeof ext}". Please update this config or remove it.

What it means

Even when `pageExtensions` is a non-empty array, each element must be a string. If any element is a number, boolean, object, or null, normalization throws with the offending element and its typeof. This guards the router's string comparisons during file matching.

Source

Thrown at packages/next/src/server/config.ts:382

        }
      }

      if (key === 'pageExtensions') {
        if (!Array.isArray(value)) {
          throw new Error(
            `Specified pageExtensions is not an array of strings, found "${value}". Please update this config or remove it.`
          )
        }

        if (!value.length) {
          throw new Error(
            `Specified pageExtensions is an empty array. Please update it with the relevant extensions or remove it.`
          )
        }

        value.forEach((ext) => {
          if (typeof ext !== 'string') {
            throw new Error(
              `Specified pageExtensions is not an array of strings, found "${ext}" of type "${typeof ext}". Please update this config or remove it.`
            )
          }
        })
      }

      const defaultValue = (defaultConfig as Record<string, unknown>)[key]

      if (
        !!value &&
        value.constructor === Object &&
        typeof defaultValue === 'object'
      ) {
        currentConfig[key] = {
          ...defaultValue,
          ...Object.keys(value).reduce<any>((c, k) => {
            const v = value[k]
            if (v !== undefined && v !== null) {

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Ensure every element is a string: cast or filter, e.g. `pageExtensions: exts.filter((e) => typeof e === 'string')`
  2. Quote any numeric-looking extensions
  3. Remove the key to use defaults

Example fix

// before
module.exports = { pageExtensions: ['tsx', 123] }
// after
module.exports = { pageExtensions: ['tsx', '123'] }
Defensive patterns

Strategy: type-guard

Validate before calling

pageExtensions = pageExtensions.filter((e) => typeof e === 'string')

Type guard

const isStringOnlyArray = (v: unknown): v is string[] =>
  Array.isArray(v) && v.every((e) => typeof e === 'string')

Prevention

When it happens

Trigger: Setting `pageExtensions: ['tsx', 123]`, `pageExtensions: ['ts', null]`, or `pageExtensions: ['js', true]`. Often from spreading mixed-type data into the array.

Common situations: Constructing extensions programmatically and accidentally including a non-string. Reading extensions from a JSON config that parsed numbers without quotes.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/979666ecebf6fb3f. Report an issue: GitHub.