Gulp 4.我的代码在哪里包含错误?

时间:2019-01-20 15:41:48

标签: gulp gulp-watch

我有一个问题,因为我正在学习有关Web开发的课程,并且在那门课程中引入了gulp以及一个人所说的话,只是简单地编码是行不通的,可能是因为它是Gulp 3,而im正在使用Gulp 4,因为没有点学习Gulp 3,即时通讯试图找到执行此任务的方法,但是在gulp 4中,观看只是不想做他的工作。 如果没有它,我现在无法继续前进,请提供帮助。

"Patryk@DESKTOP-CFM0C1O MINGW64 ~/Desktop/Strony/testgulp2 (master)
$ gulp watch
[16:24:04] Using gulpfile ~\Desktop\Strony\testgulp2\gulpfile.js
[16:24:04] Starting 'watch'...
(node:6360) UnhandledPromiseRejectionWarning: TypeError: gulp.start is not a function
    at C:\Users\Patryk\Desktop\Strony\testgulp2\gulpfile.js:19:10
    at write (C:\Users\Patryk\Desktop\Strony\testgulp2\node_modules\gulp-watch\index.js:148:3)
    at C:\Users\Patryk\Desktop\Strony\testgulp2\node_modules\gulp-watch\index.js:131:5
(node:6360) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6360) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
.

我已经在寻找不同的代码,但是发生了其他问题,但没有一个起作用。

var gulp = require('gulp'),
watch = require('gulp-watch');

gulp.task('default', function() {
  console.log("Hooray - you created a Gulp task.");
});

gulp.task('html', function() {
  console.log("Imagine something useful being done to your HTML here.");
});

gulp.task('styles', function() {
  console.log("Imagine Sass or PostCSS tasks running here.");
});

gulp.task('watch', function() {

  watch('./app/index.html', function() {
    gulp.start('html');
  });

  watch('./app/assets/styles/**/*.css', function() {
    gulp.start('styles');
  });

});

当我将它们保存在文本编辑器中时,我希望gulp查看我的css和html文件,并将它们都发送到另一个位置。

0 个答案:

没有答案