Search code examples
javascriptrequirejshandlebars.js

Handlebars 2.0 amd runtime returns undefined


I need help figuring out whats wrongs with the handlebars.runtime.amd.js

  • The first weird thing I noticed, is the different folder structure I get when installing Handlebars 2.0 using bower vs the one I get using NPM (Yes both of them were ~2.0)

My RequireJS path for the runtime module is as listed below. The path is 100% correct since I see the proper file loading in the dev tools network tab.

  paths:   {
    "handlebars": "../../node_modules/handlebars/dist/handlebars.runtime.amd",
  },

In either package (bower / npm) when I include the runtime amd module the argument in the require callback is "undefined"..

require(["app", "handlebars"], function(app, h) {
  // why is 'h' undefined?? 
})

Solution

  • The file handlebars.runtime.amd.js exports named module handlebars.runtime. Require it with this name or use handlebars.runtime.js which is also could be used as AMD module but has no predefined name.