sveltejs/kit · error · Error
${keypath} should be true or false, if specified
Error message
${keypath} should be true or false, if specified What it means
The `boolean` validator throws when a boolean config option receives a non-boolean value. Flags like `kit.prerender.crawl`, `kit.prerender.enabled`, or `handleHttpErrors`-style toggles must be literal true/false — truthy strings such as 'true' are rejected.
Source
Thrown at packages/kit/src/core/config/options.js:469
* @returns {Validator}
*/
function number(fallback) {
return validate(fallback, (input, keypath) => {
if (typeof input !== 'number') {
throw new Error(`${keypath} should be a number, if specified`);
}
return input;
});
}
/**
* @param {boolean} fallback
* @returns {Validator}
*/
function boolean(fallback) {
return validate(fallback, (input, keypath) => {
if (typeof input !== 'boolean') {
throw new Error(`${keypath} should be true or false, if specified`);
}
return input;
});
}
/**
* @param {string[]} options
* @returns {Validator}
*/
function list(options, fallback = options[0]) {
return validate(fallback, (input, keypath) => {
if (!options.includes(input)) {
// prettier-ignore
const msg = options.length > 2
? `${keypath} should be one of ${options.slice(0, -1).map(input => `"${input}"`).join(', ')} or "${options[options.length - 1]}"`
: `${keypath} should be either "${options[0]}" or "${options[1]}"`;
throw new Error(msg);View on GitHub (pinned to 03f1687fe6)
Solutions
- Use literal true or false (unquoted) in the config.
- Convert env values explicitly: crawl: process.env.PRERENDER !== 'false'.
- Delete the key to use the documented default.
Example fix
// before
kit: { prerender: { crawl: 'true' } }
// after
kit: { prerender: { crawl: true } } Defensive patterns
Strategy: type-guard
Validate before calling
const crawl = cfg.kit?.prerender?.crawl;
if (crawl !== undefined && typeof crawl !== 'boolean') throw new Error(`crawl should be a boolean, got ${typeof crawl}`); Type guard
function isBooleanOrUndefined(v) { return v === undefined || typeof v === 'boolean'; } Try / catch
try {
validateOptions(cfg);
} catch (e) {
if (String(e.message).includes('should be true or false')) {
console.error('Boolean flag has non-boolean value:', e.message);
process.exit(1);
} else throw e;
} Prevention
- Convert env flags explicitly: process.env.X !== 'false' or === 'true'.
- Never quote true/false in svelte.config.js.
- Prefer deriving booleans with strict comparisons, not truthiness coercion.
When it happens
Trigger: Setting kit.prerender.crawl: 'false' (string) or crawl: 0 / crawl: null in svelte.config.js, then triggering config validation via build or dev.
Common situations: Boolean flags sourced from environment variables (process.env.PRERENDER is the string 'false'), or hand-edited configs quoting the value.
Related errors
- ${keypath} must be an array of strings, if specified
- ${keypath} should be a number, if specified
- ${keypath} must be a valid origin — received '${input}' whic
- Each member of ${keypath} must be either '*' or an absolute
- Unexpected option ${keypath}.${key} (did you mean config.${k
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/913f6efd8effe7b0.
Report an issue: GitHub.