Gulp AssertionError [ERR_ASSERTION]:必须指定任务函数

2024-01-07

我正在尝试为构建的 Web 应用程序的演示自定义模板AngularJS using MacOS 塞拉利昂 10.13.6。我已经安装了Gulp但当我启动时gulp serve返回此错误而不启动本地服务器:

assert.js:337 抛出错误; ^

断言错误 [ERR_ASSERTION]:任务函数必须指定于 Gulp.set [作为 _setTask] (/Users/barkia/Desktop/Elysium/repos/elysium-webapp/material/node_modules/undertaker/lib/set-task.js:10:3) 在 Gulp.task 中 (/Users/barkia/Desktop/Elysium/repos/elysium-webapp/material/node_modules/undertaker/lib/task.js:13:8) 在对象。 (/Users/barkia/Desktop/Elysium/repos/elysium-webapp/material/gulpfile.js:9:6) 在 Module._compile (内部/模块/cjs/loader.js:689:30) Object.Module._extensions..js(内部/模块/cjs/loader.js:700:10) 在 Module.load (内部/模块/cjs/loader.js:599:32) tryModuleLoad(内部/模块/cjs/loader.js:538:12)位于 Function.Module._load(内部/模块/cjs/loader.js:530:3)位于 Module.require (internal/modules/cjs/loader.js:637:17) at require (内部/模块/cjs/helpers.js:20:18)

这是 gulpfile.js 实际上在~/Desktop/Elysium/repos/elysium-webapp/material/gulpfile.js

我已经删除了之前的错误/usr/local/share/man/man1/gulp.1通过启动npm uninstall -g gulp之后npm install -g gulp但我仍然有这个问题assert.js:337

var gulp = require('gulp');
var args = require('yargs').argv;
var browserSync = require('browser-sync');
var config = require('./gulp.config')();
var del = require('del');
var $ = require('gulp-load-plugins')({lazy: true});

gulp.task('help', $.taskListing);
gulp.task('default', ['help']);

gulp.task('vet', function() {
    log('Analyzing source with JSHint and JSCS');

    return gulp
        .src(config.alljs)
        .pipe($.if(args.verbose, $.print()))
        .pipe($.jscs())
        .pipe($.jshint())
        .pipe($.jshint.reporter('jshint-stylish', {verbose: true}))
        .pipe($.jshint.reporter('fail'));
});

gulp.task('clean-tmp', function(done) {
    var files = config.tmp;
    clean(files, done);
});

gulp.task('clean', function(done) {
    var delconfig = [].concat(config.dist, config.tmp);
    log('Cleaning ' + $.util.colors.blue(delconfig));
    del(delconfig, done);
});

gulp.task('clean-all', function(done) {
    var delconfig = config.allToClean;
    log('Cleaning ' + $.util.colors.blue(delconfig));
    clean(delconfig, done);
});

gulp.task('pug-docs', function() {
    log('Compiling docs pug --> html');

    var options = {
        pretty: false
    }

    return gulp
        .src(config.docsPug)
        .pipe($.plumber({errorHandler: swallowError}))
        .pipe($.pug(options))
        .pipe(gulp.dest(config.docs));
});

gulp.task('less', function() {
    log('Compiling Less --> CSS');

    return gulp
        .src(config.less)
        .pipe($.plumber({errorHandler: swallowError}))
        .pipe($.less())
        .pipe($.autoprefixer())
        .pipe(gulp.dest(config.tmp));
});

gulp.task('less-watcher', function() {
    gulp.watch([config.less], ['less']);
});

gulp.task('sass', function() {
    log('Compiling Sass --> CSS');

    var sassOptions = {
        outputStyle: 'nested' // nested, expanded, compact, compressed
    };

    return gulp
        .src(config.sass)
        .pipe($.plumber({errorHandler: swallowError}))
        .pipe($.sourcemaps.init())
        .pipe($.sass(sassOptions))
        .pipe($.autoprefixer())
        .pipe($.sourcemaps.write())
        .pipe(gulp.dest(config.tmp + '/styles'));
});

gulp.task('sass-min', function() {
    log('Compiling Sass --> minified CSS');

    var sassOptions = {
        outputStyle: 'compressed' // nested, expanded, compact, compressed
    };

    return gulp
        .src(config.sass)
        .pipe($.plumber({errorHandler: swallowError}))
        .pipe($.sass(sassOptions))
        .pipe($.autoprefixer())
        .pipe(gulp.dest(config.tmp + '/styles'));    
})

gulp.task('sass-watcher', function() {
    gulp.watch([config.sass], ['sass']);
});

gulp.task('inject', function() {
    log('Injecting custom scripts to index.html');

    return gulp
        .src(config.index)
        .pipe( $.inject(gulp.src(config.js), {relative: true}) )
        .pipe(gulp.dest(config.client));
});

gulp.task('copy', ['sass-min'], function() {
    log('Copying assets');

    var assets = [].concat(config.assetsLazyLoad, config.assetsToCopy);

    gulp.src(config.tmp + '/styles/loader.css').pipe(gulp.dest(config.dist + '/styles'));

    return gulp
        .src(assets, {base: config.client})
        .pipe(gulp.dest(config.dist + '/'));
});

gulp.task('optimize', ['inject', 'sass-min'], function() {
    log('Optimizing the js, css, html');

    return gulp
        .src(config.index)
        .pipe($.plumber({errorHandler: swallowError}))
        .pipe($.useref())
        .pipe($.if('scripts/app.js', $.uglify()))
        .pipe(gulp.dest( config.dist ));

});


gulp.task('serve', ['inject', 'sass'], function() {
    startBrowserSync('serve');
});

gulp.task('build', ['optimize', 'copy'], function() {
    startBrowserSync('dist');
})

gulp.task('serve-dist', function() {
    gulp.run('build');
})

gulp.task('serve-docs', ['pug-docs'], function() {
    startBrowserSync('docs');
})



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

function log(msg) {
    if (typeof(msg) === 'object') {
        for (var item in msg) {
            if (msg.hasOwnProperty(item)) {
                $.util.log($.util.colors.green(msg[item]));
            }
        }
    } else {
        $.util.log($.util.colors.green(msg));
    }
}

function swallowError (error) {
    // If you want details of the error in the console
    console.log(error.toString());

    this.emit('end');
}

function startBrowserSync(opt) {
    if (args.nosync || browserSync.active) {
        return;
    }

    var options = {
        port: 3000,
        ghostMode: {
            clicks: false,
            location: false,
            forms: false,
            scroll: true
        },
        injectChanges: true,
        logFileChanges: true,
        logLevel: 'debug',
        logPrefix: 'gulp-patterns',
        notify: true,
        reloadDelay: 0, //1000,
        online: false
    };

    switch(opt) {
        case 'dist':
            log('Serving dist app');
            serveDistApp();
            break;
        case 'docs':
            log('Serving docs');
            serveDocs();
            break;
        default:
            log('Serving app');
            serveApp();
            break;
    }

    function serveApp() {
        gulp.watch([config.sass], ['sass']);

        options.server = {
            baseDir: [
                config.client,
                config.tmp
            ]
        };
        options.files = [
            config.client + '/**/*.*',
            '!' + config.sass,
            config.tmp + '/**/*.css'
        ];

        browserSync(options);
    }

    function serveDistApp() {
        options.server = {
            baseDir: [
                config.dist
            ]
        };
        options.files = [];

        browserSync(options);
    }

    function serveDocs() {
        gulp.watch([config.docsPug], ['pug-docs']);

        options.server = {
            baseDir: [
                config.docs
            ]
        }

        options.files = [
            config.docs + '/index.html',
            '!' + config.pug
        ];

        browserSync(options);
    }

}

我在升级到 gulp 4 时遇到了同样的问题。

依赖的任务必须指定为串行或并行,仅名称是不够的。

Example

gulp.task('copy', ['sass-min'], function() {

Becomes

gulp.task('copy', gulp.series('sass-min'), function() {

gulp.parallel也可用于并行执行任务

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Gulp AssertionError [ERR_ASSERTION]:必须指定任务函数 的相关文章

随机推荐

  • 使用 php/mysql 通过 IP 禁止

    我希望能够通过 IP 禁止用户 我的想法是在 BannedIPs 表中保留 IP 列表作为行 IP 列将是索引 为了根据表检查用户的 IP 我将为每个会话保留一个名为 SESSION IP 的会话变量 如果在任何请求中 SESSION IP
  • Python csv writer 是否始终使用 DOS 行尾字符?

    我意识到csvPython 中的库总是生成 DOS 行尾字符 即使我使用 wb 模式 即使我使用Linux import csv f open output txt wb writer csv writer f writer writero
  • 如何复制 YouTube 的应用导航逻辑

    我想在我的应用程序中实现导航逻辑 就像在 Youtube 应用程序中一样 BottomNavigationView Fragment 管理 我想要这个 因为这些片段很重 所以我希望它们被延迟初始化然后存储在backstack中 我觉得You
  • 使 DIV 最大高度等于“窗口高度 - 100px”

    有一个方法可以设置max height in 但是这里有什么方法可以设置 DIV max height 这样它就会比仅使用 CSS 的窗口高度小 100px 吗 它不能是固定布局 用户必须能够垂直滚动页面 但 DIV 始终应调整大小wind
  • Delphi XE6 - 如何使用户定义的组件图像显示在调色板上

    我正在从 2007 迁移到 XE6 并且有几个由我自己和第三方编写的用户定义组件 在delphi 2007中安装组件时 您只需将组件添加到库中 它就会自动找到同名的DCR并将其加载到dpk文件中 并将图像加载到调色板上 在delphi XE
  • 如何限制pytorch中的参数范围?

    所以通常在pytorch中 模型中的参数没有严格的限制 但是如果我希望它们保持在 0 1 范围内怎么办 有没有办法阻止参数更新超出该范围 一些生成对抗网络 其中一些要求判别器的参数在一定范围内 中使用的一个技巧是在每次梯度更新后限制值 例如
  • HTML 中的“href”值可在 Android 上的 YouTube 应用或市场 (Google Play) 中打开视频

    我正在制作一个显示 360 度视频的网页 但我最近注意到 Android 浏览器中不支持 360 度功能 因此视频无法正确显示 所以经过大量搜索后我发现最好的选择是尝试使用本开发人员教程中解释的 Android Intent 在 YouTu
  • 如何在 Python 中迭代坐标列表并计算它们之间的距离

    我有一个包含 20 个坐标 x 和 y 坐标 的列表 我可以计算任意两个坐标之间的距离 但我很难编写一个算法来迭代列表并计算第一个节点与每个其他节点之间的距离 例如 ListOfCoordinates 1 2 3 4 5 6 7 8 9 1
  • 如何在 tcl 中使用 split 删除不需要的字符

    这是一个例子 Interface IP Address OK Method Status Protocol FastEthernet0 0 unassigned YES unset administratively down down Fa
  • 此类不符合键的键值编码

    我对快速开发非常陌生 我正在努力本节 https developer apple com library ios referencelibrary GettingStarted DevelopiOSAppsSwift Lesson7 htm
  • MacOS:以编程方式向图像添加一些文本?

    我正在将一些代码从 Linux 转换到 Mac 如何以编程方式用文本覆盖图像 类似于 ImageMagick 转换命令 由于各种原因 我不能依赖安装 ImageMagick convert draw text 50 800 hello wo
  • 我们可以迭代 Amazon S3 中的完整对象集吗

    我尝试打印 S3 存储桶中所有对象的元数据 但是 它不会返回超过 1000 个对象的结果 我尝试过实施objectListing isTruncated 但这没有帮助 下面是我列出 1000 多个对象的示例代码 ListObjectsReq
  • Hask 局部很小吗?

    haskell 对象的类别 Hask 是局部小类别的示例吗 http ncatlab org nlab show locally small category http ncatlab org nlab show locally small
  • 使用 mod_cgi 和 mod_perl 捕获错误

    提前感谢大家 我一直在对错误处理进行一些研究 但我觉得我并没有对我应该做什么有充分的了解 前言 我的代码位于 Apache 中并在浏览器中执行 我的目标不包括命令行执行 我希望具有 CGI Carp fatalsToBrowser 的行为
  • window.open 无法打开两个以上的链接

    根据我的要求 我需要创建一个 Google Chrome 扩展程序 只需在单个 Chrome 窗口的不同选项卡中单击一次即可打开多个链接 25 该代码在 Chrome 18 之前一直运行良好 现在 我使用的是 chrome 24 该代码停止
  • 有选择地对数组中的元素取反

    我正在寻找有关 numpy 中 如何选择性地否定数组的值 的一些帮助 已经尝试过了 numpy where and numpy negative但无法对选定的少数人实施条件 import numpy as np arr np arange
  • 使用 ggplot 在 x 轴上显示有限的时间范围

    我希望下图中的 x 轴从 06 00 开始 到 22 00 结束 每 4 小时休息一次 但是 我无法弄清楚以下内容 a 如何使x轴从06 00开始 06 00之前没有任何空白 b 如何使x轴在22 00结束 22 00之后没有任何空白 现在
  • “subl”命令无法正常工作

    在终端中使用 subl 命令时遇到问题 它曾经工作正常 但最近当我运行它时 它确实打开了我想要的文件 但我无法编辑它们 而且 Sublime Text 没有显示在我的 mac 的顶部栏中 就好像它根本没有运行一样 有除了扩展坞中的图标之外也
  • 如何防止加载谷歌图表表格CSS

    每次我使用 Google Charts Table 时 Google 加载程序都会加载一个http ajax googleapis com ajax static modules gviz 1 0 table table css这总是并且几
  • Gulp AssertionError [ERR_ASSERTION]:必须指定任务函数

    我正在尝试为构建的 Web 应用程序的演示自定义模板AngularJS using MacOS 塞拉利昂 10 13 6 我已经安装了Gulp但当我启动时gulp serve返回此错误而不启动本地服务器 assert js 337 抛出错误