babel-upgrade
raw JSON → 1.0.1 verified Sat Apr 25 auth: no javascript maintenance
A tool to automatically upgrade Babel 6 projects to Babel 7. It updates dependencies, config files (.babelrc, babel key in package.json), and JavaScript files that import Babel packages directly. Stable version is v1.0.1, though previously released as v0.x. No regular release cadence; last release was in 2019. Key differentiators: it automates the rename of packages (e.g., babel-preset-env → @babel/preset-env), adds necessary peer dependencies, and handles monorepos. It is a one-time migration tool, not a general Babel upgrade utility.
Common errors
error npx: command not found ↓
cause npx is not available with older npm versions (< 5.2.0).
fix
Upgrade npm to >= 5.2.0 or install babel-upgrade globally and run without npx.
error Error: Your Node.js version is not supported. Please upgrade to Node.js >= 8.0.0. ↓
cause Node.js version is too old.
fix
Update Node.js to version 8.0.0 or higher.
error babel-upgrade: command not found ↓
cause babel-upgrade is not installed globally and npx is not used.
fix
Run 'npx babel-upgrade' or install globally: 'npm install -g babel-upgrade'.
Warnings
breaking Node.js >= 8.0.0 required. ↓
fix Update Node.js to >= 8.0.0.
breaking Upgraded projects may need manual adjustment for edge cases like custom Babel plugins. ↓
fix Review the diff output carefully; run tests after upgrade.
gotcha Without --write, only a diff is printed; no changes are made. ↓
fix Add --write or -w flag to apply changes.
deprecated The --install flag may not work with npm versions < 5.2.0 (npx not available). ↓
fix Use npm >= 5.2.0 or manually run install after upgrade.
breaking Does not handle presets or plugins that are not in the known rename list. ↓
fix Manually rename any custom or third-party presets/plugins that were not renamed.
Install
npm install babel-upgrade yarn add babel-upgrade pnpm add babel-upgrade Imports
- default (run via CLI) wrong
babel-upgrade (without --write will only print diff)correctnpx babel-upgrade --write - Programmatic API (if any) wrong
import upgrade from 'babel-upgrade' (ESM not supported)correctconst upgrade = require('babel-upgrade'); - CLI flags wrong
npx babel-upgrade (without flags as above)correctnpx babel-upgrade --write --install
Quickstart
npx babel-upgrade --write --install