Gulp文件错误:Assert错误[ERR_ASSERTION]:必须指定任务函数

mgdq6dx1  于 2022-12-08  发布在  Gulp
关注(0)|答案(1)|浏览(412)

我正在构建一个电视节目跟踪器。作为我的项目的一部分,我为一个项目创建了一个Gulpfile,但是当我运行这个文件时,我得到了下面的错误。

AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (C:\Users\bdhef\Documents\codeprojects\antenna\node_modules\undertaker\lib\set-task.js:10:3)
    at Gulp.task (C:\Users\bdhef\Documents\codeprojects\antenna\node_modules\undertaker\lib\task.js:13:8)
    at Object.<anonymous> (C:\Users\bdhef\Documents\codeprojects\antenna\gulpfile.js:16:6)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at requireOrImport (C:\Users\bdhef\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\shared\require-or-import.js:19:11) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

下面是我的Gulpfile代码

var gulp = require('gulp');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');

gulp.task('sass', function() {
    gulp.src('public/stylesheets/style.scss')
      .pipe(plumber())
      .pipe(sass())
      .pipe(gulp.dest('public/stylesheets'));
});

gulp.task('watch', function() {
    gulp.watch('public/stylesheets/*.scss', ['sass']);
});

gulp.task('default', ['sass', 'watch']);

和目录结构

node_modules/
public/
  fonts/
  stylesheets/
  vendor/
  app.js
  favicon.ico
  index.html
gulpfile.js
package-lock.json
package.json
server.js
busg9geu

busg9geu1#

gulp.任务('默认',gulp.系列('sass','watch'));

相关问题