引发断言错误

时间:2018-08-16 14:40:26

标签: javascript gulp bootstrap-4

通过相同的问题搜索无法解决。 我正在这个人的https://coursetro.com/posts/code/130/Learn-Bootstrap-4-Final-in-2018-with-our-Free-Crash-Course教程的帮助下进行bootstrap 4安装。

跟着一样:我明白了

Gulp:控制台中的错误,assert.js:90抛出新的assert.AssertionError

 AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (C:\Users\dc\Projects\main-pro
ject\bs4\node_modules\undertaker\lib\set-task.js:10:3)
    at Gulp.task (C:\Users\dc\Projects\main-project\bs4\node
_modules\undertaker\lib\task.js:13:8)
    at Object.<anonymous> (C:\Users\dc\Projects\main-project
\bs4\gulpfile.js:21:6)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

这是我的gulpfile.js

    var gulp        = require('gulp');
var browserSync = require('browser-sync').create();
var sass        = require('gulp-sass');

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
    return gulp.src(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'])
        .pipe(sass())
        .pipe(gulp.dest("src/css"))
        .pipe(browserSync.stream());
});

// Move the javascript files into our /src/js folder
gulp.task('js', function() {
    return gulp.src(['node_modules/bootstrap/dist/js/bootstrap.min.js', 'node_modules/jquery/dist/jquery.min.js', 'node_modules/popper.js/dist/umd/popper.min.js'])
        .pipe(gulp.dest("src/js"))
        .pipe(browserSync.stream());
});

// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {

    browserSync.init({
        server: "./src"
    });

    gulp.watch(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'], ['sass']);
    gulp.watch("src/*.html").on('change', browserSync.reload);
});

gulp.task('default', ['js','serve']);

1 个答案:

答案 0 :(得分:0)

最新答复,但这也许还是有帮助的。本教程使用gulp v.3,并且您已经安装了v.4。新版本要求指定任务功能。简短的答案是更改任务,例如:

gulp.task('serve', ['js','serve'], function() {...});

gulp.task('start', gulp.parallel(['js','serve'], function () {...}));

长答案需要阅读此页面https://fettblog.eu/gulp-4-parallel-and-series/