Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Task x can't support dependencies that is not an array of strings

I'm following this tutorial on how to start with gulp and browserify (amongst other plugins).

The structure as follows:

.
├── gulpfile.js
└── gulp
    ├── index.js
    └── tasks
        ├── browserify.js
        └── minifyCss.js
/* gulpfile.js */
var gulp = require('./gulp')([
    'minifyCss',
    'browserify'
]);

gulp.task('default', ['minifyCss', 'browserify']);
/* index.js */
var gulp = require('gulp');

module.exports = function(tasks) {
    tasks.forEach(function(name) {
        gulp.task(name, require('./tasks/' + name));
    });

    return gulp;
};
/* tasks/minifyCss.js */
var gulp      = require('gulp');
var minifyCss = require('gulp-minify-css');

gulp.task('minifyCss', function() {
  return gulp.src('css/*.css')
    .pipe(minifyCss())
    .pipe(gulp.dest('dist'));
})

However, when running $ gulp it produces the following error:

Error: Task minifyCss can't support dependencies that is not an array of strings
at Gulp.Orchestrator.add (/home/joao/src/joaopw/node_modules/gulp/node_modules/orchestrator/index.js:47:10)
at /home/joao/src/joaopw/gulp/index.js:5:14
at Array.forEach (native)
at module.exports (/home/joao/src/joaopw/gulp/index.js:4:11)
at Object.<anonymous> (/home/joao/src/joaopw/gulpfile.js:1:91)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

I can't seem to find what's the problem here, am I missing some arguments or? The code is not so different from the example on the tutorial.

like image 313
João Gonçalves Avatar asked Sep 03 '15 19:09

João Gonçalves


1 Answers

In your index.js file inside the forEach loop every gulp task must have a callback function, so you'll need to export one from your tasks like so:

/* tasks/minifyCss.js */
var gulp      = require('gulp');
var minifyCss = require('gulp-minify-css');

module.exports = function() {
    return gulp.src('css/*.css')
               .pipe(minifyCss())
               .pipe(gulp.dest('dist'));
 };
like image 81
Helder Lucas Avatar answered Nov 13 '22 02:11

Helder Lucas