Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp.js error on gulp.watch "Arguments to path.resolve must be strings"

I'm trying to move my file path globs into an object at the top of my gulpfile. After refactoring my gulpfile like this I started to get this error trigged by gulp.watch:

throw new TypeError('Arguments to path.resolve must be strings');

At the top of my gulpfile I've defined a variable srcFolder which should be the name of the folder that contains the source files for my project. Then I create a map containing the paths that are associated with each task and append this folder name to the beginning of each path. In this example my srcFolder is just called "src", and I am only seeing this error when I have an "src" directory to watch. For example, changing srcFolder to "foo" or changing gulp.watch to look at "foo" will not cause an error.

Here is a link to my gulpfile stripped down to a single task (styles). Line 70 is where I call gulp.watch. My gulp version is 3.6.2.

like image 791
Alex Tebbs Avatar asked Dec 08 '22 07:12

Alex Tebbs


1 Answers

It's simply poor api design. You need to pass the task list as an array, even if it is a single task.

gulp.watch(srcGlobs.style, ['styles']);

should work.

like image 173
abject_error Avatar answered May 20 '23 13:05

abject_error