Gulpfile.js failed to load

This syntax is no longer allowed in gulp4:

gulp.task('default', ['durandal']);

Use :

gulp.task('default', gulp.series('durandal'));

Likewise change to:

gulp.task('durandal', gulp.series('clean', function (done) {
    durandal({
        baseDir: 'app',
        main: 'main.js',
        output: 'main-built.js',
        almond: true,
        minify: true
    })
    .pipe(gulp.dest('app'));
    done();
});

Also, using pump would probably give you better error reporting than you are getting without it.


I have tried your setup, it indeed threw an error like yours. I went to the gulp docs and tried their version of a gulpfile, and it worked with no issues. So I have rewritten your gulpfile to match their example and it worked well. here's the code:


    var gulp = require('gulp'),
        durandal = require('gulp-durandal'),
        rimraf = require('rimraf');

    var paths = {
        app: "./App/**/*.js",
        js: "./Scripts/**/*.js",
        css: "./Content/**/*.css",
        concatJsDest: "./Scripts/vendor-scripts.min.js",
        concatCssDest: "./Content/vendor-css.min.css"
    };

    function clean (cb) {
      rimraf('app/main-built.js', cb);
    }

    gulp.task('clean', clean);

    function runDurandal () {
      return durandal({
          baseDir: 'app',
          main: 'main.js',
          output: 'main-built.js',
          almond: true,
          minify: true,
          rjsConfigAdapter: function (rjsConfig) {
              rjsConfig.deps = ['text'];
              return rjsConfig;
          }
      })
      .pipe(gulp.dest('app'));
    }

    var build = gulp.series(clean, runDurandal);

    gulp.task('default', build);

Basically I have moved functions that you use as tasks to variables, and used series to run durandal.

then I have tried npx gulp --tasks-simple and have a proper output

clean
default

btw, have a look at npx so you don't have to install gulp globally.

Hope that helps!