nul del错误在gulpfile Visual Studio 2015中 [英] npm del error in gulpfile Visual Studio 2015

查看:152
本文介绍了nul del错误在gulpfile Visual Studio 2015中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



以下是我使用的
版本的内容。

我在我的gulp文件中使用del包作为干净任务的一部分。 Visual Studio 2015社区
Node.js v2.11.3
gulp v3.9.0
del v2.0.2



这是我的大文件:

  var gulp = require('gulp'); 
var del = require('del');
var config = require('./gulp.config')();

var $ = require('gulp-load-plugins')({lazy:true});

gulp.task('images',['clean-images'],function(){
log('复制和压缩图像');

返回gulp
.src(config.images)
.pipe($。imagemin({optimizationLevel:4}))
.pipe(gulp.dest(config.build +'images' ));
});

gulp.task('clean-images',function(done){
clean(config.build +'images /**/*.*',done);
});

function clean(path,done){
log('Cleaning:'+ $ .util.colors.blue(path));
del(path,done);
}

当我运行任务 images gulp images clean-images 任务执行命令提示符$ c>,但从未结束。它的错误与行:

  [16:10:45]使用gulpfile〜\Documents\Visual Studio 2015\ Projects \ ** \Gulpfile.js 
[16:10:46]启动'clean-images'...
[16:10:46]清理:build / images / ** / *。*
过程以代码0终止。

结果,剩下的 images 任务不执行。



images 任务当我移除 clean-images 依赖关系时运行正常。



不要以前有人看到过这个问题,并知道如何改正它?



谢谢

解决方案

您遇到了与此用户相同的错误: del 模块不再使用回调,但承诺。 done 永远不会被调用,因此 clean images 任务

您可以从clean方法返回:

  gulp.task('clean-images',function(){
return clean(config.build +'images /**/*.*');
});

function clean(path){
log('Cleaning:'+ $ .util.colors.blue(path));
return del(path);
}


I'm using the del package in my gulpfile as part of a clean task.

Below are the the versions of things I'm using Visual Studio 2015 Community Node.js v2.11.3 gulp v3.9.0 del v2.0.2

This is an extract from my gulp file:

var gulp = require('gulp');
var del = require('del');
var config = require('./gulp.config')();

var $ = require('gulp-load-plugins')({ lazy: true });

gulp.task('images', ['clean-images'], function () {
    log('Copying and compressing the images');

    return gulp
        .src(config.images)
        .pipe($.imagemin({optimizationLevel: 4}))
        .pipe(gulp.dest(config.build + 'images'));
});

gulp.task('clean-images', function (done) {
    clean(config.build + 'images/**/*.*', done);
});

function clean(path, done) {
    log('Cleaning: ' + $.util.colors.blue(path));
    del(path, done);
}

When I run the task images from the command prompt using gulp images the clean-images task executes but never finishes. It errors with the lines:

[16:10:45] Using gulpfile ~\Documents\Visual Studio 2015\Projects\**\Gulpfile.js
[16:10:46] Starting 'clean-images'...
[16:10:46] Cleaning: build/images/**/*.*
Process terminated with code 0.

As a result the rest of the images task doesn't execute.

The images task runs fine when I remove the clean-images dependency.

Don't suppose anyone has seen this issue before, and knows how to correct it?

Thanks

解决方案

I think you've encountered the same error as this user : the del module doesn't use callbacks anymore, but promises. done is never called, so the clean and images task run concurrently, which causes an error.

You could just return from the clean method :

gulp.task('clean-images', function () {
    return clean(config.build + 'images/**/*.*');
});

function clean(path) {
    log('Cleaning: ' + $.util.colors.blue(path));
    return del(path);
}

这篇关于nul del错误在gulpfile Visual Studio 2015中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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