Skip to content

Gulp 4: TypeError: undefined is not a function when passing array inside array #1287

@demisx

Description

@demisx
$ gulp -v
[10:23:57] CLI version 0.4.0
[10:23:57] Local version 4.0.0-alpha.1

We have a watch:code task defined like this:

var paths = {
  html: ['app/**/*.shtml', 'app/**/*.html'],
  js: 'app/**/*.js',
  images: 'app/**/*.{JPG,jpg,png,gif}',
  json: 'app/**/*.json',
  ... ... ...
}

gulp.task('watch:code', function () {
  gulp.watch([
    paths.html,
    paths.js,
    paths.images,
    paths.json
    ], gulp.series('build', browserSync.reload));
});

Running this task generates this error now:

[10:21:25] Starting 'watch:code'...
[10:21:25] 'watch:code' errored after 3.53 ms
[10:21:25] TypeError: undefined is not a function
    at EventEmitter.FSWatcher._getWatchHelpers (/Users/dmoore/projects/amgen-sites/sensiparhcp-com-templates/node_modules/gulp/node_modules/chokidar/index.js:241:15)
    at EventEmitter.FsEventsHandler._addToFsEvents (/Users/dmoore/projects/amgen-sites/sensiparhcp-com-templates/node_modules/gulp/node_modules/chokidar/lib/fsevents-handler.js:292:17)
    at Array.forEach (native)
    at EventEmitter.FSWatcher.add (/Users/dmoore/projects/amgen-sites/sensiparhcp-com-templates/node_modules/gulp/node_modules/chokidar/index.js:420:11)
    at Object.exports.watch (/Users/dmoore/projects/amgen-sites/sensiparhcp-com-templates/node_modules/gulp/node_modules/chokidar/index.js:508:33)
    at Gulp.watch (/Users/dmoore/projects/amgen-sites/sensiparhcp-com-templates/node_modules/gulp/index.js:38:26)
    at /Users/dmoore/projects/amgen-sites/sensiparhcp-com-templates/gulpfile.js:242:8
    at bound (domain.js:254:14)
    at runBound (domain.js:267:12)
    at asyncRunner (/Users/dmoore/projects/amgen-sites/sensiparhcp-com-templates/node_modules/gulp/node_modules/undertaker/node_modules/bach/node_modules/async-done/index.js:38:18)

The error seems to happen when passing an array of paths to the gulp.watch() function when one or more of those paths is also an array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions