我正在尝试使用gulp,当我运行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)
我的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/'))
为了找出错误发生的位置,我甚至试过
gulp.task 'scripts', ['clean'], ->
gulp.src('**/*.coffee').pipe(debug({verbose: true}))
我收到了同样的错误消息。
我做错了什么?
答案 0 :(得分:0)
您需要require
所有模块,就像您对gulp
所做的那样,而不只是指定名称:
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