{"record":{"id":"6a602b9137399df2","repo":"react/create-react-app","slug":"preset-react-app-name-option-must-be-a-boole","errorCode":null,"errorMessage":"Preset react-app: '${name}' option must be a boolean.","messagePattern":"Preset react-app: '(.+?)' option must be a boolean\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/babel-preset-react-app/create.js","lineNumber":17,"sourceCode":"/**\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';\n\nconst path = require('path');\n\nconst validateBoolOption = (name, value, defaultValue) => {\n  if (typeof value === 'undefined') {\n    value = defaultValue;\n  }\n\n  if (typeof value !== 'boolean') {\n    throw new Error(`Preset react-app: '${name}' option must be a boolean.`);\n  }\n\n  return value;\n};\n\nmodule.exports = function (api, opts, env) {\n  if (!opts) {\n    opts = {};\n  }\n\n  var isEnvDevelopment = env === 'development';\n  var isEnvProduction = env === 'production';\n  var isEnvTest = env === 'test';\n\n  var useESModules = validateBoolOption(\n    'useESModules',\n    opts.useESModules,\n    isEnvDevelopment || isEnvProduction","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/react/create-react-app/blob/6254386531d263688ccfa542d0e628fbc0de0b28/packages/babel-preset-react-app/create.js#L1-L35","documentation":"babel-preset-react-app's create.js validates every option it accepts through validateBoolOption. If a passed option is defined but is not strictly of type 'boolean', the preset refuses to load. This is a hard guard: the preset only flips features on/off, so any non-boolean (string, number) is treated as a programmer error rather than coerced.","triggerScenarios":"Calling the preset with an options object where one of its boolean keys (e.g. development, absoluteRuntime, or any plugin toggle the preset forwards) holds a non-boolean value such as the string \"true\", the number 1, or null. The check is `typeof value !== 'boolean'` after defaulting undefined.","commonSituations":"Developers read NODE_ENV/BABEL_ENV from process.env and pass it directly into the preset options (strings leak in). Copy-pasting a config snippet that quotes booleans. Migrating from an older preset whose options accepted different types. Wrapping the preset in another preset that forwards options verbatim.","solutions":["Inspect the preset options object passed in your babel.config.js / .babelrc and ensure every value meant as a toggle is a real JavaScript boolean (true/false), not a string.","If sourcing values from environment variables, coerce explicitly: Boolean(process.env.MY_FLAG) or process.env.MY_FLAG === 'true'.","Remove the offending key entirely if you want the preset default (undefined is accepted and replaced with defaultValue).","If forwarding options from a wrapper, filter/whitelist which keys you pass through to avoid leaking non-boolean values."],"exampleFix":"// before\n{\n  presets: [['react-app', { development: process.env.NODE_ENV === 'development' ? 'yes' : 'no' }]]\n}\n// after\n{\n  presets: [['react-app', { development: process.env.NODE_ENV === 'development' }]]\n}","handlingStrategy":"validation","validationCode":"// Before invoking the preset, assert every toggle is boolean.\nfunction sanitizePresetOpts(opts = {}) {\n  const boolKeys = ['development', 'absoluteRuntime', 'runtime', 'flow', 'typescript'];\n  const out = {};\n  for (const k of Object.keys(opts)) {\n    const v = opts[k];\n    if (boolKeys.includes(k) && v !== undefined) {\n      if (typeof v !== 'boolean') {\n        throw new TypeError(`Option '${k}' must be boolean, got ${typeof v}`);\n      }\n      out[k] = v;\n    } else {\n      out[k] = v;\n    }\n  }\n  return out;\n}\n// usage:\n// presets: [['react-app', sanitizePresetOpts(myOpts)]]","typeGuard":"const isBoolOrUndefined = (v) => v === undefined || typeof v === 'boolean';\nconst hasValidBoolOpts = (opts) =>\n  Object.values(opts || {}).every(isBoolOrUndefined);","tryCatchPattern":"try {\n  require('babel-core').transform(code, {\n    presets: [['react-app', opts]],\n  });\n} catch (e) {\n  if (/option must be a boolean/.test(e.message)) {\n    console.error('Preset option type error. Check non-boolean values in:', opts);\n  }\n  throw e;\n}","preventionTips":["Never forward raw process.env string values into preset options; coerce with Boolean(...) or === 'true'.","Centralize your babel preset options in one typed config builder and reuse it.","When wrapping react-app preset, whitelist only the keys you intend to support.","Add a unit test that asserts all option values you pass are booleans."],"tags":["babel","config","boolean","preset","validation"],"backgroundTag":null,"analyzedSha":"6254386531d263688ccfa542d0e628fbc0de0b28","analyzedAt":"2026-08-12T22:55:01.751Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}