babel-watch
raw JSON → 7.8.1 verified Sat Apr 25 auth: no javascript
A fast file watcher and restarter for babel-node apps. Instead of restarting babel-node on each change (which is slow), it runs babel transpilation once in a master process and spawns a plain node child with the transpiled code. Current stable version is 7.8.1, with a maintenance release cadence. Key differentiators: autowatch (automatically watches files as they are required), faster restarts than nodemon+babel-node, and supports Babel 7.
Common errors
error babel-watch: error: unknown option `--config-file' ↓
cause Using --config-file with babel-watch versions older than 7.5.0 which do not support that option.
fix
Update babel-watch to v7.5.0 or later: npm install babel-watch@latest
error Error: Cannot find module '@babel/core' ↓
cause @babel/core is a peer dependency of babel-watch and must be installed separately.
fix
Install @babel/core: npm install --save-dev @babel/core
error babel-watch: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory ↓
cause The process ran out of memory due to large files or circular requires causing infinite loops.
fix
Increase Node memory limit with --max_old_space_size, or exclude unnecessary directories with --ignore.
error (node:12345) [DEP0005] DeprecationWarning: ... ↓
cause Using deprecated debug options (-d or -B).
fix
Use --inspect or --inspect-brk instead.
error Error: listen EADDRINUSE :::9229 ↓
cause Another process is already using the inspector port when using --inspect without a custom port.
fix
Specify a different port with --inspect 0.0.0.0:9230
Warnings
breaking babel-watch v7 requires Node >= 8 and @babel/core ^7.0.0. It will not work with older Node versions or Babel 6. ↓
fix Update Node to >=8 and install @babel/core@^7.
gotcha When using --ignore, node_modules are ignored by default. If you specify a custom --ignore, you must include node_modules explicitly if you still want to ignore it. ↓
fix Use --ignore 'node_modules' along with other patterns, e.g., --ignore 'node_modules,dist'.
gotcha The --inspect option's address must be specified as a separate argument when using = syntax may cause issues. ↓
fix Use --inspect 0.0.0.0:9229 instead of --inspect=0.0.0.0:9229.
deprecated The -d and -B debug options are deprecated; use --inspect or --inspect-brk instead. ↓
fix Replace -d with --inspect and -B with --inspect-brk.
gotcha Autowatch may ignore files in node_modules by default but may still watch them if they are required. Use -x to exclude additional directories. ↓
fix Pass -x node_modules to exclude node_modules from autowatch.
Install
npm install babel-watch yarn add babel-watch pnpm add babel-watch Quickstart
{
"scripts": {
"start": "babel-watch src/main.js"
}
}
# Then run:
npm start