本文介绍了如何解决类型错误this.merge不是试图运行Mozart应用的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试启动Mozart应用,但没有任何内容呈现,并且出现了错误...

I'm trying to start a Mozart app, but nothing is rendering and I'm getting the error...

TypeError: this.merge is not a function 
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};

任何明显相关的事物都没有改变-即尚未更改模板等,因此很难发现出了什么问题.尝试过npm安装并重新运行无济于事.有人遇到这个问题吗?

Nothing obviously related has changed - ie. haven't changed the templates etc so it's hard to see what's wrong. Have tried an npm install and re-run to no avail. Anyone hit this problem?

推荐答案

听起来预编译模板所用的Handlebars版本与页面上实际运行的版本不同.

It sounds like the version of Handlebars used to precompile your templates is different to the version actually running on your page.

具体来说,this.merge是在Handlebars 1.0.0 final中添加的,因此,如果您的页面仍在运行早期版本(如1.0.0rc4),则该方法将不存在,并且一切都会中断.

Specifically, this.merge was added in Handlebars 1.0.0 final, so if your page is still running an earlier version (like 1.0.0rc4) the method won't exist and things will break.

您需要更新页面上使用的Handlebars的版本,或者在package.json中回退用于模板预编译的Handlebars的版本.

You need to either update the version of Handlebars used on your page, or drop back the version of Handlebars being used for template precompilation in package.json.

您有时还会因NPM安装下游依赖项的方式而遇到麻烦.例如,您可以在package.json中指定"handlebars": "1.0.11",但是如果另一个程序包依赖于Handlebars并使用了不同的版本,那么当被调用.您可以通过运行npm install --production来解决此问题,以确保跳过重复的依赖项(无论版本如何),但是最重要的一点可能是更新到最新版本并保持一致".

You can also sometimes get into trouble due to the way downstream dependencies are installed by NPM. For example, you might specify "handlebars": "1.0.11" in your package.json, but if another package has a dependency on Handlebars and uses a different version, it can be a bit of a lottery as to which version of Handlebars will be loaded when require() is called. You can get around this by running npm install --production to ensure duplicate dependencies are skipped (regardless of version), but the bottom line is probably "update to the latest version and stay consistent".

这篇关于如何解决类型错误this.merge不是试图运行Mozart应用的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 13:33