{"id":19307,"library":"babel-preset-kyt","title":"babel-preset-kyt","description":"An opinionated Babel preset for kyt, the NY Times frontend toolkit. Current stable version is 1.1.21 (last released May 2025). It provides a pre-configured Babel setup for React and TypeScript projects, supporting both ESM and CJS modules. Key differentiators: tightly integrated with kyt for zero-config transpilation, includes presets for environment-specific builds (browser, node), and handles module transforms. Alternatives like @babel/preset-env and @babel/preset-react require manual configuration.","status":"active","version":"1.1.21","language":"javascript","source_language":"en","source_url":"https://github.com/nytimes/kyt","tags":["javascript","babel","babel-preset","kyt","react","typescript"],"install":[{"cmd":"npm install babel-preset-kyt","lang":"bash","label":"npm"},{"cmd":"yarn add babel-preset-kyt","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-preset-kyt","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: required for Babel compilation","package":"@babel/core","optional":false},{"reason":"core preset for modern JavaScript","package":"@babel/preset-env","optional":false},{"reason":"preset for React JSX/transform","package":"@babel/preset-react","optional":false},{"reason":"preset for TypeScript support","package":"@babel/preset-typescript","optional":true}],"imports":[{"note":"Preset is CommonJS; ESM import is not supported directly. Use require() or use .babelrc presets array.","wrong":"import preset from 'babel-preset-kyt'","symbol":"default export","correct":"module.exports = require('babel-preset-kyt')"},{"note":"Use full package name to avoid resolution ambiguity.","wrong":"{\"presets\": [\"kyt\"]}","symbol":"preset in .babelrc","correct":"{\"presets\": [\"babel-preset-kyt\"]}"},{"note":"Options must be in an array: [preset, options].","wrong":"{\"presets\": [\"babel-preset-kyt\", { \"modules\": false }]}","symbol":"preset with options","correct":"{\"presets\": [[\"babel-preset-kyt\", { \"modules\": false }]]}"}],"quickstart":{"code":"// .babelrc\n{\n  \"presets\": [\"babel-preset-kyt\"]\n}\n\n// Or in babel.config.js\nmodule.exports = {\n  presets: [\"babel-preset-kyt\"],\n  // optionally override env targets\n  env: {\n    browser: {\n      presets: [[\"babel-preset-kyt\", { targets: \"> 0.25%, not dead\" }]]\n    },\n    node: {\n      presets: [[\"babel-preset-kyt\", { targets: { node: \"current\" } }]]\n    }\n  }\n}","lang":"javascript","description":"Configures babel-preset-kyt in .babelrc and babel.config.js with environment-specific targets."},"warnings":[{"fix":"Use require() or configure via .babelrc/babel.config.js.","message":"Preset is CommonJS only; ESM import will fail with 'require is not defined' error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use nested arrays: \"presets\": [[\"babel-preset-kyt\", { ... }]]","message":"Options must be passed as array elements: [preset, options]. Direct object after preset string is ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"npm install @babel/preset-typescript --save-dev and add to presets array.","message":"If using TypeScript, ensure @babel/preset-typescript is installed separately.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install babel-preset-kyt --save-dev","cause":"Missing package installation","error":"Error: Cannot find module 'babel-preset-kyt'"},{"fix":"Use require() or configure via .babelrc/babel.config.js (CommonJS).","cause":"Using ESM import to load preset","error":"Error: Plugin/Preset files are not allowed to export objects, only functions."},{"fix":"Verify .babelrc or babel.config.js includes 'babel-preset-kyt' in presets array.","cause":"Preset not applied; possibly missing configuration","error":"SyntaxError: Unexpected token import"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}