【问题标题】:Gulpjs – gulp-jade compilation issueGulpjs – gulp-jade 编译问题
【发布时间】:2015-12-08 14:59:20
【问题描述】:

我在使用 gulpJs 模块时遇到了一个我无法弄清楚的错误 gulp-jade

> [11:13:59] TypeError: listener must be a function
>     at DestroyableTransform.addListener (events.js:197:11)
>     at DestroyableTransform.Readable.on (/Users/ME/Sites/temp/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:718:33)
>     at Gulp.<anonymous> (/Users/ME/Sites/temp/gulpfile.js:14:16)
>     at module.exports (/Users/ME/Sites/temp/node_modules/orchestrator/lib/runTask.js:34:7)
>     at Gulp.Orchestrator._runTask (/Users/ME/Sites/temp/node_modules/orchestrator/index.js:273:3)
>     at Gulp.Orchestrator._runStep (/Users/ME/Sites/temp/node_modules/orchestrator/index.js:214:10)
>     at Gulp.Orchestrator.start (/Users/ME/Sites/temp/node_modules/orchestrator/index.js:134:8)
>     at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
>     at doNTCallback0 (node.js:428:9)
>     at process._tickCallback (node.js:357:13)

我已经正确安装了模块,我的 gulpfile 是:

var gulp = require('gulp');
var jade = require('gulp-jade');

gulp.task('markup', function() {
  gulp.src('jade/**/*.jade')
  .pipe(jade().on('error', jade.logError))
  .pipe(gulp.dest('/build'));
});

【问题讨论】:

  • 那么jade.logError 不是函数吗?

标签: javascript node.js gulp pug


【解决方案1】:

问题出在这一行:.pipe(jade().on('error', jade.logError)) - 我相信jade 不包含类似logError 的任何内容。试试这样的:.pipe(jade().on('error', console.log))

【讨论】:

  • 对,通过删除该行来工作...但我的代码还没有编译为 html...只需将我的翡翠文件复制到 /build/
  • 真的忘了 .pipe(jade()) :)
猜你喜欢
  • 2014-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-15
  • 1970-01-01
相关资源
最近更新 更多