Gulp在控制台出现错误后停止工作
[18:26:36] Starting 'sass'...
events.js:174
throw er; // Unhandled 'error' event
^
Error: src\scss\style.scss
Error: property "background-color" must be followed by a ':'
on line 7 of src/scss/style.scss
>> background-color
----^
at options.error (C:\Users\puux\Desktop\test\node_modules\node-sass\lib\index.js:291:26)
Emitted 'error' event at:
at DestroyableTransform.onerror (C:\Users\puux\Desktop\test\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:558:12)
at DestroyableTransform.emit (events.js:189:13)
at onwriteError (C:\Users\puux\Desktop\test\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:449:12)
at onwrite (C:\Users\puux\Desktop\test\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:470:11)
at WritableState.onwrite (C:\Users\puux\Desktop\test\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:180:5)
at DestroyableTransform.afterTransform (C:\Users\puux\Desktop\test\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:93:3)
at errorM (C:\Users\puux\Desktop\test\node_modules\gulp-sass\index.js:118:12)
at Object.callback (C:\Users\puux\Desktop\test\node_modules\gulp-sass\index.js:127:16)
at options.error (C:\Users\puux\Desktop\test\node_modules\node-sass\lib\index.js:294:32)
此后,我必须再次在控制台中输入gulp。 如何避免这种情况?
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
gulp.task('reload', function(){
browserSync.reload();
});
gulp.task('serve', ['sass'], function(){
browserSync({
server: 'src'
});
gulp.watch('src/*.html', ['reload']);
});
gulp.watch('src/scss/**/*scss', ['sass']);
gulp.task('sass', function(){
return gulp.src('src/scss/**/*scss')
.pipe(sass().on('erorr', sass.logError))
.pipe(gulp.dest('src/css'))
.pipe(browserSync.stream());
});
gulp.task('default', ['serve']);
这是我的代码。 每个错误之后,我都不想再次开始吞咽。 我认为它不应该这样工作,而我的js代码却做得不好。