Registry / serialization / babel-preset-stage-2

babel-preset-stage-2

JSON →
library6.24.1jsnpmunverified

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.

npm install babel-preset-stage-2
INSTALL
IMPORT
SIG · BABEL-PRESET-STAGE
B
babel-preset-stage-2
serializationjavascriptv6.24.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (preset)
module.exports = { presets: ['stage-2'] }
import stage2 from 'babel-preset-stage-2'
This is a Babel 6 preset, not a JS module. Use string name in .babelrc or Node API.
require for Node API
require('babel-core').transform(code, { presets: ['stage-2'] })
const stage2 = require('babel-preset-stage-2'); ... presets: [stage2]
Presets are resolved by string name; passing the module directly may cause version mismatches.
Babel 7 replacement
npm install @babel/preset-env @babel/plugin-proposal-optional-chaining // .babelrc: { presets: [['@babel/preset-env', { targets: '> 0.25%' }]] }
npm install @babel/preset-stage-2
Babel 7 removed stage presets. Use @babel/preset-env with targets or individual proposal plugins.

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);
Debug
Known issues
deprecatedbabel-preset-stage-2 is deprecated in favor of @babel/preset-env.
fix
Use @babel/preset-env with targets or add individual proposal plugins.
affects: >=6.0.0
breakingBabel 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.
affects: >=6.24.1
gotchaUsing 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).
affects: >=6.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-preset-stage-2'
Missing npm install of the preset.
fix
Run: npm install --save-dev babel-preset-stage-2
ReferenceError: [BABEL] unknown preset: stage-2
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.
Upgrade
Version history
6.24.1latest on npm
Audit
Dependencies
babel-preset-stage-3requiredStage 2 preset includes stage 3 plugins
babel-plugin-syntax-trailing-function-commasoptionalIncluded in stage 2 preset
Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources