babel-preset-env

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

A Babel preset that automatically determines the transforms and polyfills needed for target environments (browsers or Node.js versions) based on browserslist queries. Version 1.7.0 is the last stable release before merging into the Babel monorepo. Deprecated in favor of @babel/preset-env (Babel 7). No longer maintained as a standalone package. Use @babel/preset-env for continued support and updates.

error Error: Cannot find module 'babel-preset-env'
cause Package not installed or typo in name.
fix
npm install babel-preset-env --save-dev
error ReferenceError: regeneratorRuntime is not defined
cause Async/await or generator functions need runtime polyfill.
fix
Add 'transform-runtime' plugin or ensure core-js polyfill includes regenerator.
error Module not found: Can't resolve 'core-js/modules/es6.promise'
cause Using useBuiltIns: 'usage' with outdated core-js.
fix
Install core-js@2 (or 3) and set 'corejs' option accordingly.
deprecated babel-preset-env is deprecated. Use @babel/preset-env for Babel 7+.
fix Replace 'babel-preset-env' with '@babel/preset-env' and update Babel to v7+.
breaking useBuiltIns: true was renamed to 'usage' in v2 alpha. In v1, true is invalid.
fix Use 'entry' or 'usage' (Babel 7) instead of true.
gotcha Without specifying targets, it behaves like babel-preset-latest (transpiles everything).
fix Always set targets to reduce output size and avoid unnecessary transforms.
gotcha useBuiltIns: 'entry' requires importing core-js at the entry point (e.g., import 'core-js'). Usage mode does not.
fix Add import 'core-js' at app entry when using 'entry' mode.
npm install babel-preset-env
yarn add babel-preset-env
pnpm add babel-preset-env

Configure babel-preset-env with browserslist targets and useBuiltIns for automatic polyfill inclusion.

// .babelrc
{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["> 0.25%", "not dead"]
      },
      "useBuiltIns": "usage",
      "corejs": 2
    }]
  ]
}

// Then in your build script:
// npx babel src --out-dir lib
// For polyfills, ensure core-js@2 is installed.