我遇到了返回TypeError的gulp-handlebars问题:Handlebars.template不是一个函数。它一直工作相对完美,直到现在它似乎已经停止。我在这里缺少什么想法?
在bower文件夹中查看把手显示为与节点模块文件夹相同的3.0.3。查看生成的编译模板文件,但是所有模板似乎都显示"编译器":[6,"> = 2.0.0-beta.1"]我怀疑这可能是原因
console.log浏览器中的句柄返回把手,但模板属性是一个空对象
我的package.json
"devDependencies": {
"handlebars": "^3.0.3",
"gulp": "^3.8.11",
"gulp-clean": "^0.3.1",
"gulp-concat": "^2.5.2",
"gulp-declare": "^0.3.0",
"gulp-handlebars": "^4.0.0",
"gulp-jshint": "^1.9.2",
"gulp-rename": "^1.2.0",
"gulp-sequence": "^0.3.2",
"gulp-uglify": "^1.1.0",
"gulp-watch": "^4.1.1",
"gulp-wrap": "^0.11.0",
"gulp-yuidoc": "^0.1.2"
}
我的bower.json
"dependencies": {
"bootstrap": "~3.3.2",
"jquery": "~2.1.3",
"sammy": "~0.7.6",
"showdown": "~0.4.0",
"handlebars": "3.0.3",
"pagedown": "~1.1.0"
},
"devDependencies": {
"jqueryui": "~1.11.4"
}
我的吞咽任务
gulp.task('templates', function() {
gulp.src(['public/templates/**/*.hbs', 'public/templates/*.hbs'])
.pipe(handlebars({
handlebars: require('handlebars')
}))
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'Handlebars.templates',
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat('templates.js'))
.pipe(gulp.dest('public/js/'));
});
gulp.task('watch', function() {
gulp.watch(['public/templates/*.hbs', 'public/templates/**/*.hbs'], ['templates']);
gulp.watch(['public/js/*.js', 'public/js/**/*.js'], ['build']);
});
链接到Github问题 - https://github.com/lazd/gulp-handlebars/issues/55
由于
答案 0 :(得分:0)
通过gulp连接和缩小时,请确保您的路径正确。 Mine改变了,gulp没有发现任何关于找不到文件的错误!