Babel Preset Angular
raw JSON → 6.0.15 verified Sat Apr 25 auth: no javascript deprecated
Babel preset for all Angular plugins. Current stable version is 6.0.15. This package bundles multiple Babel transforms needed for Angular applications. It is designed for older Angular (1.x) projects; for Angular 2+ (now Angular), use the Angular compiler instead. The preset is not actively maintained and relies on legacy Babel 6. Release cadence is low; no recent updates. Key differentiator: simplifies configuration by grouping Angular-specific Babel plugins.
Common errors
error require is not defined ↓
cause Using ESM import syntax with babel-core in a CommonJS environment.
fix
Use require instead of import: const babel = require('babel-core');
error Error: Cannot find module 'babel-preset-angular' ↓
cause Missing npm install or incorrect require path.
fix
Run 'npm install --save-dev babel-preset-angular' and ensure node_modules is present.
error Unknown plugin 'angular' specified in ↓
cause Using an outdated Babel version that doesn't support unnamed plugins.
fix
Use Babel 6 or check preset naming.
Warnings
deprecated babel-preset-angular is not actively maintained and uses Babel 6, which is end-of-life. ↓
fix Migrate to a modern Angular build system (e.g., Angular CLI with @angular/compiler-cli).
breaking The preset includes babel-preset-es2015 which doesn't support modern JavaScript features like async/await beyond ES2015. ↓
fix Add additional presets like babel-preset-stage-2 or use babel-preset-env.
gotcha Using the full preset name 'babel-preset-angular' in .babelrc presets array does not work; Babel expects short name 'angular'. ↓
fix Use 'angular' (omitting 'babel-preset-') in the presets array.
Install
npm install babel-preset-angular yarn add babel-preset-angular pnpm add babel-preset-angular Imports
- default wrong
require('babel-preset-angular')correctmodule.exports = { presets: ['angular'] } - preset wrong
{ "presets": ["babel-preset-angular"] }correct{ "presets": ["angular"] } - plugins wrong
import preset from 'babel-preset-angular'correctrequire('babel-core').transform('code', { presets: [require('babel-preset-angular')] })
Quickstart
// Ensure you have babel-cli and babel-preset-angular installed
// npm install --save-dev babel-cli babel-preset-angular
// Create .babelrc file with:
{
"presets": ["angular"]
}
// Then run:
// babel script.js --out-file script-compiled.js