繁体   English   中英

TypeError:Handlebars.template不是函数Handlebars 3.0.3

[英]TypeError: Handlebars.template is not a function Handlebars 3.0.3

我在返回TypeError的gulp-handlebars时遇到问题:Handlebars.template不是函数。 到目前为止,它一直在相对完美地工作,但是似乎已经停止了。 有什么想法我在这里想念的吗?

在Bower文件夹中查找的车把显示为3.0.3,与节点模块文件夹相同。 查看生成的已编译模板文件,但是所有模板似乎都显示“ compiler”:[6,“> = 2.0.0-beta.1”],我怀疑这可能是原因

浏览器中的console.log车把返回车把,但是template属性是一个空对象

我的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

谢谢

在连接和最小化时,请确保您的路径正确。 我的换了,gulp并没有因为找不到文件而抛出任何错误!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM