Gulp file error: AssertionError [ERR_ASSERTION]: Task function must be specified
Gulp file error: AssertionError [ERR_ASSERTION]: Task function must be specified
我正在构建电视节目跟踪器。作为我项目的一部分,我为项目创建了一个 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
gulp.task('default', gulp.series('sass', 'watch'));
我正在构建电视节目跟踪器。作为我项目的一部分,我为项目创建了一个 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
gulp.task('default', gulp.series('sass', 'watch'));