gulp-flatten icon indicating copy to clipboard operation
gulp-flatten copied to clipboard

TypeError: Cannot read property 'reduce' of undefined

Open JamesLMilner opened this issue 8 years ago • 2 comments

Hey, thanks for the library.

I'm having issues using gulp-flatten. I am using

  return gulp.src('./components/**/*.pug')
        // .pipe(print())
        .pipe(flatten())
        .pipe(pug({ verbose : false }))
        .pipe(gulp.dest("./../public/templates/"))

also tried

  return gulp.src('./components/**/*.pug')
        // .pipe(print())
        .pipe(pug({ verbose : false }))
        .pipe(flatten())
        .pipe(gulp.dest("./../public/templates/"))

Both produce the following error:

 TypeError: Cannot read property 'reduce' of undefined
    at _flatten (/home/james/Code/3drepo.io/frontend/node_modules/flatten/index.js:14:16)
    at flatten (/home/james/Code/3drepo.io/frontend/node_modules/flatten/index.js:11:10)
    at Gulp.<anonymous> (/home/james/Code/3drepo.io/frontend/gulpfile.js:56:15)
    at module.exports (/home/james/Code/3drepo.io/frontend/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/james/Code/3drepo.io/frontend/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/james/Code/3drepo.io/frontend/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/home/james/Code/3drepo.io/frontend/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

Using: Node.js LTS 6.11.2 Gulp 3.9.1

JamesLMilner avatar Aug 10 '17 12:08 JamesLMilner

Hey, @JamesMilnerUK

Sorry for late reply. Could you try following:

gulp.src('./components/**/*.pug')
        .pipe(flatten())
        .pipe(gulp.dest("./../public/templates/"))

Does it work?

armed avatar Aug 12 '17 03:08 armed

I believe you tried using the flatten package, and not gulp-flatten.

npm install gulp-flatten --save-dev
var flatten = require('gulp-flatten');

TheDancingCode avatar Apr 13 '18 21:04 TheDancingCode