Registry / devops / babel-preset-airbnb

babel-preset-airbnb

JSON →
library5.0.0jsnpmunverified

A Babel preset for transforming JavaScript according to the Airbnb Style Guide, version 5.0.0. It includes transforms for all stage 4 (ES2018) and stage 3 syntax permitted in the guide, excluding generators, async/await, async iterators, and lifted template literal restrictions. It uses @babel/preset-env for targeting environments and supports React development mode, PropTypes removal, and optional loose class mode. Peer dependencies include @babel/core ^7.0.0 and @babel/runtime ^7.0.0. Differentiators: opinionated selection based on Airbnb style, built-in support for React PropTypes removal, and environment targeting via @babel/preset-env. Released as needed, with last major update aligning with Babel 7.

npm install babel-preset-airbnb
INSTALL
IMPORT
SIG · BABEL-PRESET-AIRBN
B
babel-preset-airbnb
devopsjavascriptv5.0.0
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: ['airbnb'] };
module.exports = { presets: ['babel-preset-airbnb'] };
In .babelrc or babel.config.js, use the shorthand 'airbnb'. The full package name also works but is less common.
with options
module.exports = { presets: [['airbnb', { targets: { node: 6 } }]] };
Options are passed as an array. Common mistakes include missing inner array brackets.
require in Node API
require('@babel/core').transform('code', { presets: [['airbnb', { targets: { node: 6 } }]] });
var preset = require('babel-preset-airbnb'); require('@babel/core').transform('code', { presets: [preset] });
The preset is resolved by name; passing the preset object directly may cause plugin duplication issues.

Quick setup for babel-preset-airbnb with Node.js target, React development mode, and PropTypes removal toggle.

// Install: npm install --save-dev babel-preset-airbnb @babel/core @babel/runtime // .babelrc or babel.config.js module.exports = { presets: [['airbnb', { targets: { node: 'current' }, development: process.env.NODE_ENV === 'development', removePropTypes: process.env.NODE_ENV === 'production', loose: false }]] };
Debug
Known issues
breakingVersion 5.0.0 is for Babel 7. Do not use with Babel 6.
fix
Use babel-preset-airbnb@3 for Babel 6, or upgrade to Babel 7.
affects: >=5.0.0
gotchaThe preset excludes generators, async/await, and async iterators due to regenerator-runtime overhead.
fix
If you need these features, add @babel/plugin-transform-regenerator and @babel/plugin-transform-async-to-generator manually.
affects: >=3.0.0
gotchaPropTypes removal is opt-in via the 'removePropTypes' option and defaults to 'wrap' mode, not 'remove'.
fix
Set removePropTypes: true or removePropTypes: { mode: 'remove' } for production builds.
affects: >=5.0.0
deprecatedThe 'additionalTargets' option may be deprecated in future versions; use 'targets' directly.
fix
Merge your custom targets into the 'targets' object instead of using 'additionalTargets'.
affects: >=5.0.0
gotchaWhen using debug mode (debug: true), output can be verbose and may expose internal plugin lists.
fix
Only enable debug for troubleshooting; avoid in CI or production logs.
affects: >=4.0.0
gotchaThe preset requires @babel/runtime as a peer dependency, not just @babel/core.
fix
Add @babel/runtime to your dependencies or devDependencies.
affects: >=5.0.0
Errors
Common errors & fixes
Cannot find module '@babel/core'
Missing peer dependency @babel/core.
fix
npm install --save-dev @babel/core @babel/runtime
Error: Cannot find module 'babel-preset-airbnb'
Preset not installed or in wrong devDependencies.
fix
npm install --save-dev babel-preset-airbnb
SyntaxError: Unexpected token (1:1) while parsing /path/to/file.js with Babel preset 'airbnb'
Using Babel 6 with babel-preset-airbnb@5 (Babel 7 preset).
fix
Downgrade to babel-preset-airbnb@3 or upgrade Babel to v7.
ReferenceError: regeneratorRuntime is not defined
Using async/await or generators, which are excluded from the preset.
fix
If needed, add @babel/plugin-transform-runtime or @babel/polyfill.
Error: Plugin 0 specified in "..." provided an invalid property of type "boolean" (expected object)
Incorrect configuration: presets: ['airbnb', { targets: ... }] (should be nested array).
fix
Use presets: [['airbnb', { targets: ... }]]
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency; Babel 7 core is required for the preset to function.
@babel/runtimerequiredPeer dependency; provides helper functions for transformed code.
Agent activity
8 hits · last 30 days
node
8
Resources
babel-preset-airbnb — npm install babel-preset-airbnb · libregistry