sveltejs/kit · error · Error
${keypath} must be an array of strings
Error message
${keypath} must be an array of strings What it means
The `extensions` config option controls which file extensions SvelteKit treats as routable pages. It must be an array whose every member is a string. SvelteKit throws this when the value is not an array or contains non-string entries.
Source
Thrown at packages/kit/src/core/config/options.js:127
{
tracing: removed(
(keypath) =>
`\`${keypath}\` has been removed. Server-side tracing is now configured via \`tracing.server\``
),
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'),View on GitHub (pinned to 03f1687fe6)
Solutions
- Wrap the value in an array: `extensions: ['.svelte']`
- Ensure every member is a string — remove non-string entries
- If building from an env var, split it: `process.env.EXTENSIONS?.split(',') ?? ['.svelte']`
Example fix
// before
const config = { extensions: '.svelte,.js' };
// after
const config = { extensions: ['.svelte', '.js'] }; Defensive patterns
Strategy: type-guard
Validate before calling
if (!Array.isArray(config.extensions) || !config.extensions.every((e) => typeof e === 'string')) {
throw new Error('extensions must be an array of strings');
} Type guard
function isStringArray(v) {
return Array.isArray(v) && v.every((e) => typeof e === 'string');
} Try / catch
try {
build({ config });
} catch (e) {
if (String(e.message).includes('must be an array of strings')) {
console.error('Wrap extensions in an array of strings');
}
throw e;
} Prevention
- Always write extension lists as arrays with quoted string members
- When deriving from env vars, split strings into arrays explicitly
- Add a config sanity check script in CI before building
When it happens
Trigger: Setting `extensions` to a string (e.g. `extensions: '.svelte'`), to a non-array value, or to an array containing numbers/objects/null (e.g. `extensions: ['.svelte', null]`).
Common situations: Hand-editing svelte.config.js and forgetting array brackets; generating config from JSON where an env list is comma-joined into a single string; typos like `extensions: ['.svelte', 1]`.
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
- Invalid isr.expiration value: ${JSON.stringify(value)} (${de
- The SvelteKit options from the Vite config must be an object
- ${keypath} should be "fail", "warn", "ignore" or a custom fu
- The SvelteKit Vite plugin ${keypath} should be an object wit
- ${keypath} should be an object
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/f0955917df48b2bc.
Report an issue: GitHub.