Babel Stage 2 Preset

raw JSON →
6.24.1 verified Sat Apr 25 auth: no javascript deprecated

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.

error Error: Cannot find module 'babel-preset-stage-2'
cause Missing npm install of the preset.
fix
Run: npm install --save-dev babel-preset-stage-2
error ReferenceError: [BABEL] unknown preset: stage-2
cause Using package name with @babel/core (Babel 7) which doesn't support the old preset naming.
fix
Migrate to @babel/preset-env: npm install --save-dev @babel/preset-env and configure in .babelrc.
deprecated babel-preset-stage-2 is deprecated in favor of @babel/preset-env.
fix Use @babel/preset-env with targets or add individual proposal plugins.
breaking Babel 7 removed stage presets entirely; this package does not work with @babel/core.
fix Migrate to @babel/preset-env and specific plugins like @babel/plugin-proposal-optional-chaining.
gotcha Using both stage-2 and stage-3 presets together causes duplicate plugin errors.
fix Only use the highest stage preset needed (stage-2 includes stage-3).
npm install babel-preset-stage-2
yarn add babel-preset-stage-2
pnpm add babel-preset-stage-2

Shows installation and basic usage of babel-preset-stage-2 with .babelrc and Node API.

// Step 1: Install
npm install --save-dev babel-cli babel-preset-stage-2

// Step 2: Create .babelrc
{
  "presets": ["stage-2"]
}

// Step 3: Compile
babel script.js --out-file script-compiled.js

// Or programmatically with Node API
const babel = require('babel-core');
const result = babel.transform('const x = {...obj}', {
  presets: ['stage-2']
});
console.log(result.code);