Gulp4迁移-无效的Glob参数 [英] Gulp4 migration - Invalid glob argument

查看:238
本文介绍了Gulp4迁移-无效的Glob参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究从3.9.0版到gulp 4.0.0版的gulp迁移.

I'm working on gulp migration from version 3.9.0 to gulp version 4.0.0.

我在gulp.src('')上的gulpfile.js中遇到错误,错误消息是错误:无效的全局参数:"

I'm getting an error in the gulpfile.js on gulp.src('') and the error message is "Error: Invalid glob argument: "

我在gulpfile.js中的gulp.task()看起来像这样-

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);
        });});

和gulp版本:4.0.0,节点版本:8.11.4

and the gulp version : 4.0.0, Node version : 8.11.4

我的错误消息:在此处输入图像描述

请在终端中找到错误消息的图像.

Please find the image of the error message in the terminal.

是否有人知道如何解决该问题.

Does anyone has any idea how can I resolve the issue.

推荐答案

我偶然发现了这个问题,并通过研究对该问题进行了发现,因为似乎并不能完全解决问题.

I stumbled on this question and found thru research the issue since it seems it doesn't look to be fully answered.

是的,此问题源于gulp.src('')为空,但是在Gulp 3中这是可以的,并且默认情况下允许.

Yes the issue stems from gulp.src('') being empty but in Gulp 3 this was ok and allowed by default.

根据Gulp文档(不是从迁移的观点出发,是为4.0编写的,它是事实的来源),看来您可以传入选项 allowEmpty,默认情况下为false.因此,如果代码中包含gulp.src(''),则还需要指定allowEmpty选项.

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.

他们为上下文提供的示例是src(globs, [options])

An example they provide for the context is src(globs, [options])

这里是一个例子:gulp.src('', {allowEmpty: true})

如果这不起作用,我读过的其他文章都说:gulp.src([], {allowEmpty: true})或: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!

这篇关于Gulp4迁移-无效的Glob参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆