Reputation: 51
I'm working on gulp migration from version 3.9.0 to gulp version 4.0.0.
I'm getting an error in the gulpfile.js on gulp.src('') and the error message is "Error: Invalid glob argument: "
My gulp.task() in gulpfile.js looks like this -
gulp.task('build-version', function(done) {
var dir = path.build + '/js',
filename = "build.js";
gulp.src('')
.pipe(ngConfig('ppm', {
createModule: false,
constants: {
newUIBuildVersion: buildVersion
}
}))
.pipe(rename(filename))
.pipe(gulp.dest(dir));
// lint build.js file
return gulp.src(dir + '/' + filename)
.pipe(jshint(config.jshint))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'))
.on('error', function(err) {
log(err);
});});
and the gulp version : 4.0.0, Node version : 8.11.4
My error message : enter image description here
Please find the image of the error message in the terminal.
Does anyone has any idea how can I resolve the issue.
Upvotes: 5
Views: 10542
Reputation: 307
I stumbled on this question and found thru research the issue since it seems it doesn't look to be fully answered.
Yes the issue stems from gulp.src('')
being empty but in Gulp 3 this was ok and allowed by default.
According to the Gulp docs (written for 4.0 as source of truth not from a migration standpoint), it appears that you can pass in a option allowEmpty
which is false by default. So if you have in your code gulp.src('')
you will need to specify the allowEmpty
option as well.
An example they provide for the context is src(globs, [options])
Here's an example: gulp.src('', {allowEmpty: true})
If that doesn't work, other articles I read said : gulp.src([], {allowEmpty: true})
or : gulp.src('.', {allowEmpty: true})
Here's a link for all the options if you run into other issues.
https://gulpjs.com/docs/en/api/src#errors
Hope this helps! Thanks!
Upvotes: 7