【发布时间】:2016-07-04 10:25:36
【问题描述】:
我在控制台中收到这样的错误: $一口
assert.js:90
throw new assert.AssertionError({
^
AssertionError: Task function must be specified
at Gulp.set [as _setTask] (C:\Users\user\Projects\New project\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (C:\Users\user\Projects\New project\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (C:\Users\user\Projects\New project\gulpfile.js:44:6)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
这是我的 gulpfile:
var gulp = require('gulp');
var build = require('gulp-build');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var browser_sync = require('browser-sync');
var gulps = require("gulp-series");
//gulp-build
gulp.task('build', function() {
gulp.src('scripts/*.js')
.pipe(build({
GA_ID: '123456'
}))
.pipe(gulp.dest('dist'))
});
//gulp-sass
gulp.task('sass', function() {
return gulp.src('scss/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true,
outputStyle: 'expanded'
}).on('error', sass.logError))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('css'));
});
//gulp-browser-sync
gulp.task('browser_sync', function() {
var files = [
'*.html',
'css/*.css'
];
browser_sync.init(files, {
server: {
baseDir: './'
}
});
});
//gulp-watch
gulp.task('watch', ['sass'], function() {
gulp.watch('scss/**/*.scss', ['sass']);
});
//gulp-series
gulps.registerTasks({
"test1": (function(done) {
setTimeout(function() {
console.log("test1 is done");
done();
}, 1000);
}),
"test2": (function() {
console.log("test2 is done");
})
});
gulps.registerSeries("default", ["test1", "test2"]);
// gulp.task('default', ['watch', 'browser_sync'], function() {});
我只是一个初学者,你知道我做错了什么吗?
【问题讨论】:
-
@SurajRao:这是正式评论。在这种情况下,它是不需要的。一个链接就足够了。 “Michael Oxborrow”——很好的链接,tnx。
标签: javascript gulp