【问题标题】:Gulp unhandled errorGulp 未处理的错误
【发布时间】:2015-07-16 15:33:03
【问题描述】:

我有一个非常简单的 gulp 文件,其中包含几个任务: - 清理文件夹 - 复制文件

我有一个手表设置。我不断收到错误消息:

events.js:85 投掷者; // 未处理的“错误”事件 ^ 错误:ENOENT,打开 '/Users/gordon/Dropbox/Dev/MDR/ScribeTab/dist/font/Roboto-Regular-webfont.woff'

我不明白出了什么问题,就像我说的,有时它在我运行手表时有效,有时它在手表上失败,有时在我对弹出窗口进行更改后运行手表任务(默认)时失败。 html.

这是我完整的 gulpfile:

var gulp = require('gulp'),
    plumber = require('gulp-plumber'),
    path = require('path'),
    del = require('del')

    gulp.task('default', ['clean', 'copy'])

    gulp.task('clean', function(){
      return del('dist/**/*');
    });

    gulp.task('copy', function() {

      /* copy fonts */
      var fonts = gulp.src('src/font/*')
        .pipe(gulp.dest("dist/font"));

      /* copy images */
      var imgs = gulp.src('src/img/*')
        .pipe(gulp.dest("dist/img"));

      /* copy html files */
      var html = gulp.src('src/**/*.html')
        .pipe(gulp.dest("dist"));

      /* copy manifest file for google chrome */
      var manifest =  gulp.src('src/manifest.json')
        .pipe(gulp.dest('dist'));

    });

    // watch
    gulp.task('watch', ['default'], function () {
        gulp.watch(['src/popup.html'], ['default']);
    });

【问题讨论】:

    标签: gulp gulp-watch


    【解决方案1】:

    听起来有些东西可能出了问题,也许先试试copy,然后再试试clean

    还可以尝试添加此错误记录功能:

    function errorlog(err) {
        console.log(err.message);
        this.emit('end');
    }
    

    gulp.task('clean', function() {
        return del('dist/**/*')
        .on('error', errorlog);
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-26
      • 2017-07-20
      • 1970-01-01
      • 2014-08-28
      • 1970-01-01
      相关资源
      最近更新 更多