Hugo Durães
Hugo Durães

Reputation: 65

Using gulp.src to match all subdirectories of a given directory, excluding given directory

I'm using gulp and gulp-chug to match all subdirectories of a given directory. What I want to perform is to watch several projects gulpfiles.

I want to match all gulpfile.js files inside subdirectories:

/path/to/dir/dir1/gulpfile.js
/path/to/dir/dir2/dir3/gulpfile.js
/path/to/dir/dir4/gulpfile.js

While excluding:

/path/to/dir/

I'm using the following pattern on gulp.src:

/path/to/dir/**/*.js

When I run the gulp task, I get the following error:

Unable to find local gulp. Try running 'npm install gulp' from /path/to/dir/.

Shouldn't /path/to/dir/ be excluded by the given pattern? Why is it looking for gulp on a directory that I don't want to be matched? Gulp is not installed on /path/to/dir/ because I don't want to search for gulpfiles on this directory.

Thanks in advance!

Upvotes: 1

Views: 2452

Answers (1)

OverZealous
OverZealous

Reputation: 39570

Look again. The error message actually tells you what's wrong and how to fix it.

You don't have the gulp npm package installed in your local project. There's two parts to gulp. The global gulp only installs the command-line application, you still need gulp installed within your project.

Go to your directory, and run the command it tells you to:

npm install gulp

// or, better run this:

npm install --save-dev gulp

Or, rather, follow the installation instructions for gulp.

Upvotes: 1

Related Questions