gulpfile 错误 AssertionError [ERR_ASSERTION]: 必须指定任务函数

gulpfile error AssertionError [ERR_ASSERTION]: Task function must be specified

当我在我的终端上 运行 gulp 时,我不断得到这个堆栈跟踪。我已经将 gulp 版本降级到 3.9.1,但我仍然遇到同样的错误。我在网上看到降级应该可以解决这个问题,但目前似乎没有帮助。

AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (/Users/ABC/react_site/my-react-project/node_modules/undertaker/lib/set-task.js:10:3)
    at Gulp.task (/Users/yasirk/react_site/my-react-project/node_modules/undertaker/lib/task.js:13:8)
    at Object.<anonymous> (/Users/ABC/react_site/my-react-project/gulpfile.js:37:6)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)

这是我的 gulpfile.js

'use strict';

//dependenices
var gulp = require('gulp');
var sass = require('gulp-sass');
var minifyCSS = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var changed = require('gulp-changed');


//////////////
// -SCSS/CSS
//////////////

var SCSS_SRC = '.src/Assets/scss/**/*.scss';
var SCSS_DEST = './src/Assets/css';

//Compile CSS
gulp.task('compile_scss', function(){

    gulp.src(SCSS_SRC)
    .pipe(sass().on('error', sass.logError))
    .pipe(minifyCSS())
    .pipe(rename({suffix: '.min' }))
    .pipe(changed(SCSS_DEST))
    .pipe(gulp.dest(SCSS_DEST));

});

// detect changes in SCSS
gulp.task('watch_scss', function(){
    gulp.watch(SCSS_SRC, ['compile_scss']);
});

// Run tasks
gulp.task('default', ['watch_scss']);

这是我的package.json,你可以看到我的gulp版本已经降级了

{
  "name": "my-react-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-scripts": "3.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "gulp": "3.9.1",
    "gulp-changed": "^4.0.1",
    "gulp-clean-css": "^4.2.0",
    "gulp-rename": "^1.4.0",
    "gulp-sass": "^4.0.2",
    "gulp-uglify": "^3.0.2"
  }
}

希望它能在您的代码中发挥作用。

gulp.task('compile_scss', function () {
    return gulp.src(SCSS_SRC)
        .pipe(scss().on('error', scss.logError))
        .pipe(minifyCSS())
        .pipe(rename({suffix: '.min' }))
        .pipe(changed(SCSS_DEST))
        .pipe(gulp.dest(SCSS_DEST))
});


// detect changes in SCSS
gulp.task('watch_scss', function(){
    gulp.watch(SCSS_SRC, gulp.parallel('compile_scss'));
});

// Run tasks
gulp.task('default', gulp.parallel('watch_scss'));