{"id":19339,"library":"babel-preset-stage-2","title":"Babel Stage 2 Preset","description":"Babel preset that includes all stage 2 (draft) ECMAScript proposal plugins. Version 6.24.1 is the last stable release; the package is effectively deprecated as Babel 7+ removed stage presets in favor of individual plugin opt-in. Use @babel/preset-env with targets or manually specify proposal plugins. This preset was part of the Babel 6.x era and should not be used for new projects.","status":"deprecated","version":"6.24.1","language":"javascript","source_language":"en","source_url":"https://github.com/babel/babel/tree/master/packages/babel-preset-stage-2","tags":["javascript"],"install":[{"cmd":"npm install babel-preset-stage-2","lang":"bash","label":"npm"},{"cmd":"yarn add babel-preset-stage-2","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-preset-stage-2","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Stage 2 preset includes stage 3 plugins","package":"babel-preset-stage-3","optional":false},{"reason":"Included in stage 2 preset","package":"babel-plugin-syntax-trailing-function-commas","optional":true}],"imports":[{"note":"This is a Babel 6 preset, not a JS module. Use string name in .babelrc or Node API.","wrong":"import stage2 from 'babel-preset-stage-2'","symbol":"default (preset)","correct":"module.exports = { presets: ['stage-2'] }"},{"note":"Presets are resolved by string name; passing the module directly may cause version mismatches.","wrong":"const stage2 = require('babel-preset-stage-2'); ... presets: [stage2]","symbol":"require for Node API","correct":"require('babel-core').transform(code, { presets: ['stage-2'] })"},{"note":"Babel 7 removed stage presets. Use @babel/preset-env with targets or individual proposal plugins.","wrong":"npm install @babel/preset-stage-2","symbol":"Babel 7 replacement","correct":"npm install @babel/preset-env @babel/plugin-proposal-optional-chaining\n// .babelrc: { presets: [['@babel/preset-env', { targets: '> 0.25%' }]] }"}],"quickstart":{"code":"// Step 1: Install\nnpm install --save-dev babel-cli babel-preset-stage-2\n\n// Step 2: Create .babelrc\n{\n  \"presets\": [\"stage-2\"]\n}\n\n// Step 3: Compile\nbabel script.js --out-file script-compiled.js\n\n// Or programmatically with Node API\nconst babel = require('babel-core');\nconst result = babel.transform('const x = {...obj}', {\n  presets: ['stage-2']\n});\nconsole.log(result.code);","lang":"javascript","description":"Shows installation and basic usage of babel-preset-stage-2 with .babelrc and Node API."},"warnings":[{"fix":"Use @babel/preset-env with targets or add individual proposal plugins.","message":"babel-preset-stage-2 is deprecated in favor of @babel/preset-env.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Migrate to @babel/preset-env and specific plugins like @babel/plugin-proposal-optional-chaining.","message":"Babel 7 removed stage presets entirely; this package does not work with @babel/core.","severity":"breaking","affected_versions":">=6.24.1"},{"fix":"Only use the highest stage preset needed (stage-2 includes stage-3).","message":"Using both stage-2 and stage-3 presets together causes duplicate plugin errors.","severity":"gotcha","affected_versions":">=6.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install --save-dev babel-preset-stage-2","cause":"Missing npm install of the preset.","error":"Error: Cannot find module 'babel-preset-stage-2'"},{"fix":"Migrate to @babel/preset-env: npm install --save-dev @babel/preset-env and configure in .babelrc.","cause":"Using package name with @babel/core (Babel 7) which doesn't support the old preset naming.","error":"ReferenceError: [BABEL] unknown preset: stage-2"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}