获取TypeError:dest.on不是函数错误

时间:2018-08-24 18:00:26

标签: gulp

这是我的Gulpfile.js的内容:

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

// BROWSER SYNC IS HERE
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;

gulp.task('workflow', function(){
  console.log('! >>>Workflow task launching<<< !');
  gulp.src('scss/**/*.scss')
  .pipe(sass().on('error', sass.logError))
  .pipe(gulp.dest('dist/css'))
  .pipe(
    browserSync.init({
      server: "./"
    })
  );
});

gulp.task('indexreload', function(){
  console.log('index reload is working');
  gulp.src('index.html')
  .pipe(
    browserSync.init({
      server:"./"
    })
  );
});

gulp.task('default', function(){
  console.log('! >>>Hey, the default task is starting<<< !');
  gulp.watch('scss/**/*.scss', ['workflow']);
  gulp.watch('scss/**/*.scss').on('change', reload);
  gulp.watch('index.html').on('change', reload);
});

这是package.json文件的样子:

{
  "name": "2018-redesign",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Nikhil Vijayan",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "latest",
    "gulp": "latest",
    "gulp-autoprefixer": "latest",
    "gulp-plumber": "latest",
    "gulp-sass": "latest"
  }
}

我不确定这是否有用,但是这是我得到的错误:

TypeError: dest.on is not a function
    at DestroyableTransform.Stream.pipe (internal/streams/legacy.js:28:8)
    at Gulp.<anonymous> (/Users/nikhil/Dropbox/Code/nkhil.com/2018-redesign/gulpfile.js:17:4)
    at module.exports (/Users/nikhil/Dropbox/Code/nkhil.com/2018-redesign/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/nikhil/Dropbox/Code/nkhil.com/2018-redesign/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/nikhil/Dropbox/Code/nkhil.com/2018-redesign/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/nikhil/Dropbox/Code/nkhil.com/2018-redesign/node_modules/orchestrator/index.js:134:8)
    at Gulp.<anonymous> (/Users/nikhil/Dropbox/Code/nkhil.com/2018-redesign/node_modules/gulp/index.js:36:18)
    at Gaze.<anonymous> (/Users/nikhil/Dropbox/Code/nkhil.com/2018-redesign/node_modules/glob-watcher/index.js:18:14)
    at Gaze.emit (events.js:182:13)
    at Gaze.emit (/Users/nikhil/Dropbox/Code/nkhil.com/2018-redesign/node_modules/gaze/lib/gaze.js:129:32)

该页面仍会重新加载到我的浏览器中,但我想知道自己在做错什么才能得到此错误。

我已经安装了autoprefixer软件包,但是我已将其注释掉,以防引起问题。

我是一个初学者,已经经历了相关的SO线程,我在没有多大帮助的情况下就可以找到它。

0 个答案:

没有答案