Question

I am trying to use gulp and I am receiving the following error when I run gulp scripts:

[13:07:39] 'scripts' errored after 1.37 ms
[13:07:39] TypeError: string is not a function
  at Gulp.<anonymous> (/development/tcs/sandbox/frontend/gulpfile.coffee:23:32)
  at module.exports (/development/tcs/sandbox/frontend/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
  at Gulp.Orchestrator._runTask (/development/tcs/sandbox/frontend/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
  at Gulp.Orchestrator._runStep (/development/tcs/sandbox/frontend/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
  at /development/tcs/sandbox/frontend/node_modules/gulp/node_modules/orchestrator/index.js:279:18
  at finish (/development/tcs/sandbox/frontend/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
  at /development/tcs/sandbox/frontend/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:52:4
  at f (/development/tcs/sandbox/frontend/node_modules/gulp/node_modules/orchestrator/node_modules/end-of-stream/node_modules/once/once.js:16:25)
  at Transform.onend (/development/tcs/sandbox/frontend/node_modules/gulp/node_modules/orchestrator/node_modules/end-of-stream/index.js:31:18)
  at Transform.EventEmitter.emit (events.js:117:20)
  at /development/tcs/sandbox/frontend/node_modules/gulp-clean/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:942:16
  at process._tickCallback (node.js:415:13)

My gulpfile.coffee

gulp = require 'gulp'

coffee = 'gulp-coffee'
concat = 'gulp-concat'
uglify = 'gulp-uglify'
sourcemaps = require 'gulp-sourcemaps'
clean = require 'gulp-clean'
gutil = 'gulp-util'
debug = 'gulp-debug'

gulp.task 'clean', ->
  gulp.src(bases.dist)
    .pipe(clean())

gulp.task 'scripts', ['clean'], ->
  gulp.src('**/*.coffee')
    .pipe(sourcemaps.init())
    .pipe(coffee({bare: true})).on('error', gutil.log)
    .pipe(uglify())
    .pipe(concat('all.min.js'))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('public/javascripts/'))

In order to find where the error was occurring, I even tried

gulp.task 'scripts', ['clean'], ->
  gulp.src('**/*.coffee').pipe(debug({verbose: true}))

and I received the same error message.

What am I doing wrong?

Was it helpful?

Solution

You need to require all your modules just as you did for gulp, not just specify the name :

gulp = require 'gulp'

coffee = require 'gulp-coffee'
concat = require 'gulp-concat'
uglify = require 'gulp-uglify'
sourcemaps = require 'gulp-sourcemaps'
clean = require 'gulp-clean'
gutil = require 'gulp-util'
debug = require 'gulp-debug'

//Example using the coffee syntax for your scripts task
gulp.task 'scripts', ['clean'], ->
  gulp.src ['**/*.coffee']
    .pipe debug verbose: true
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top