0

I am working through a react tutorial that is using eslint. When I type:

eslint **/*.js

it returns 'argument list too long' when I run from the project root. The following works, but does not include all the files.

eslint **/*.js

The problem, however, is not eslint, as the following results in the same error.

ls **/*.js

and

ls */*.js

This is not a big project and the only folder with a number of folders in it is the node_modules folder.

Why is it giving this error for a relatively small area and is there a way to capture all js files in the folder and subfolders?

Aserre
  • 4,916
  • 5
  • 33
  • 56
notthehoff
  • 1,172
  • 1
  • 12
  • 28
  • If you're getting this with a small number of files (and not-exceptionally-long file/directory names), chances are you've `export`ed a ton of cruft to your environment. Environment variables and command-line arguments live in the same space. – Charles Duffy Nov 30 '17 at 16:16
  • ...look through the output of `env`, and figure out what doesn't need to be there. (If a variable doesn't need to be accessible to subprocesses, then you can set it as a regular shell variable without exporting it!) – Charles Duffy Nov 30 '17 at 16:21

1 Answers1

0

Either:

printf '%s\0' **/*.js | xargs -0 eslint

...or...

find . -name '*.js' -exec eslist {} +

...will run a larger number of eslint invocations, each having only as many arguments as will fit on a single invocation's command line.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441