Sunday, 16 June 2013

Uncaught TypeError: Object has no method 'merge'

So you are using Handlebars.js for your dynamic content in your Javascript app, and it's almost show time so you are precompiling your .handlebars files and swapping your handlebars.js for handlebars.runtime.js, both of which are the latest version from the Handlebars website... basically following the process laid out by Tal Bereznitskey here

but the first time you run the app locally, you see in your console is a big red error that reads
Uncaught TypeError: Object #<Object> has no method 'merge'

the problem here is that your js app's version of handlebars is different to that the precompiler used.
Even though you downloaded and updated it all today...

The quick and dirty fix here is to copy from
/usr/local/lib/node_modules/handlebars/dist/

the files handlebars.runtime.min.js or handlebars.runtime.js and use that instead of the file you downloaded from the Handlebars website.  Who knows what version of Handlebars you are using now (1.0.10?), but at least its the version that actually works with your precompiler.

File under "ugly but works", I guess.

No comments:

Post a Comment