#9565·babel

Files passed to `--ignore` are also watched

Author: dahjelleCreated Feb 22, 2019Updated Sep 2, 2026
Labelshelp wantedclaimedpkg: cli

Bug Report

Current Behavior I was hitting an error message of "System limit for number of file watchers reached", and it turns out that this was because I was doing something like:

bash
npx babel . --out-dir=../es5 --watch --ignore="node_modules"

But, since --ignore was not getting passed to chokidar, it was trying to watch the entire node_modules directory—hence the error!

Expected behavior/code I would expect --watch to also respect the --ignore option.

Babel Configuration (.babelrc, package.json, cli command)

javascript
module.exports = {
  presets: ["@babel/env"],
  sourceType: "script"
};

Environment

  • Babel version(s): 7.3.3
  • Node/npm version: 10.15.1/6.8.0
  • OS: CentOS 7.5
  • Monorepo: no
  • How you are using Babel: cli

Possible Solution I attempted but failed in a patch: https://github.com/babel/babel/pull/9559 This failed as chokidar uses globs for their --ignored flag and Babel uses RegExp.

Is there another way to avoid the issue? I recognize it is more usual to run babel against a src directory or the like…but one doesn't always have that luxury on legacy code.

Thanks!