remix-run/remix · error · Error

Route-map loader returned invalid children for "${name}".

Error message

Route-map loader returned invalid children for "${name}".

What it means

The `children` field of every node (both groups and route leaves) must be an array. This error fires when children is missing or not an array during tree validation.

Source

Thrown at packages/cli/src/lib/route-map.ts:255

  if (typeof value !== 'object' || value == null) {
    throw new Error('Route-map loader returned an invalid route node.')
  }

  let key = Reflect.get(value, 'key')
  let name = Reflect.get(value, 'name')
  let kind = Reflect.get(value, 'kind')
  let children = Reflect.get(value, 'children')

  if (typeof key !== 'string' || typeof name !== 'string') {
    throw new Error('Route-map loader returned a route node without a valid name.')
  }

  if (kind !== 'group' && kind !== 'route') {
    throw new Error(`Route-map loader returned an unknown node kind for "${name}".`)
  }

  if (!Array.isArray(children)) {
    throw new Error(`Route-map loader returned invalid children for "${name}".`)
  }

  if (kind === 'group') {
    return {
      children: children.map((child) => assertRawRouteTreeNode(child)),
      key,
      kind,
      name,
    }
  }

  let method = Reflect.get(value, 'method')
  let pattern = Reflect.get(value, 'pattern')

  if (typeof method !== 'string' || typeof pattern !== 'string') {
    throw new Error(`Route-map loader returned an invalid route leaf for "${name}".`)
  }

View on GitHub (pinned to 9696913134)

Solutions

  1. Reinstall dependencies to align remix versions
  2. Add `children: []` to leaf nodes in test fixtures
  3. Regenerate the tree from the real worker
Defensive patterns

Strategy: validation

Validate before calling

tree.every(n => Array.isArray((n as any).children))

Type guard

function hasChildren(n: unknown): n is { children: unknown[] } {
  return Array.isArray((n as any)?.children)
}

Prevention

When it happens

Trigger: A node where children is undefined/null/object — typically schema drift between worker and validator versions, or hand-built test data omitting children.

Common situations: Version mismatch after partial upgrade; fixtures that model leaves without a children array.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/ac40ef0a8f9422b7. Report an issue: GitHub.