sveltejs/kit · error · Error

Each member of ${keypath} must start with '.' — saw '${exten

Error message

Each member of ${keypath} must start with '.' — saw '${extension}'

What it means

Config validation error from SvelteKit's options validator for the `extensions` field. Each entry (e.g. '.svelte') must begin with a dot so the framework can match route/component files by extension; this fires during config validation when a user supplies an extension string like 'svelte' without the leading '.'.

Source

Thrown at packages/kit/src/core/config/options.js:132

			instrumentation: removed(
				(keypath) =>
					`\`${keypath}\` has been removed. \`src/instrumentation.server.js\` is now included in the build automatically when it exists; no opt-in is required`
			),
			remoteFunctions: boolean(false),
			forkPreloads: boolean(false),
			handleRenderingErrors: removed()
		},
		true
	),

	extensions: validate(['.svelte'], (input, keypath) => {
		if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
			throw new Error(`${keypath} must be an array of strings`);
		}

		input.forEach((extension) => {
			if (extension[0] !== '.') {
				throw new Error(`Each member of ${keypath} must start with '.' — saw '${extension}'`);
			}

			if (!/^(\.[a-z0-9]+)+$/i.test(extension)) {
				throw new Error(`File extensions must be alphanumeric — saw '${extension}'`);
			}
		});

		return input;
	}),

	files: object({
		src: string('src'),
		assets: string('static'),
		hooks: object({
			client: string(null),
			server: string(null),
			universal: string(null)
		}),

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Add a leading dot to each extension: `'svelte'` becomes `'.svelte'`
  2. Normalize programmatically: `list.map((e) => e.startsWith('.') ? e : '.' + e)` before assigning

Example fix

// before
export default { extensions: ['svelte', 'svx'] };
// after
export default { extensions: ['.svelte', '.svx'] };
Defensive patterns

Strategy: validation

Validate before calling

for (const ext of config.extensions ?? []) {
  if (typeof ext !== 'string' || !ext.startsWith('.')) {
    throw new Error(`Extension '${ext}' must start with '.'`);
  }
}

Type guard

function hasLeadingDot(v) {
  return Array.isArray(v) && v.every((e) => typeof e === 'string' && e.startsWith('.'));
}

Try / catch

try {
  normalizeExtensions(config.extensions);
} catch (e) {
  if (String(e.message).includes("must start with '.'")) {
    console.error('Add a leading dot to each extension');
  }
  throw e;
}

Prevention

When it happens

Trigger: Config like `extensions: ['svelte']` or `extensions: ['.svelte', 'svx']` — any member whose first character is not `.`.

Common situations: Writing extension names without leading dots in svelte.config.js; reading extension names from filenames (e.g. `file.name.split('.').pop()` yields `svelte` without a dot).

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/0d0ccbc115257b09. Report an issue: GitHub.